htaccess配置跳过规则

时间:2012-02-21 16:20:53

标签: apache .htaccess mod-rewrite url-rewriting

我已将mytaccess配置为检查并将移动设备重定向到特定网络。但是如果REQUEST_URI是/ page / ...(博客网址)

我想跳过这个规则

我有像这样的.htaccess

RewriteBase /
RewriteEngine On

# Check if mobile=1 is set and set cookie 'mobile' equal to 1
RewriteCond %{QUERY_STRING} (^|&)mobile=1(&|$)
RewriteRule ^ - [CO=mobile:1:%{HTTP_HOST}]

# Check if mobile=0 is set and set cookie 'mobile' equal to 0
RewriteCond %{QUERY_STRING} (^|&)mobile=0(&|$)
RewriteRule ^ - [CO=mobile:0:%{HTTP_HOST}]

# cookie can't be set and read in the same request so check
RewriteCond %{QUERY_STRING} (^|&)mobile=0(&|$)
RewriteRule ^ - [S=1]

# Check if this looks like a mobile device
RewriteCond %{HTTP:x-wap-profile} !^$ [OR]
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC,OR]
RewriteCond %{HTTP:Profile}       !^$

# Check if we're not already on the mobile site
RewriteCond %{HTTP_HOST}          !^m\.
# Check to make sure we haven't set the cookie before
RewriteCond %{HTTP:Cookie}        !\mobile=0(;|$)
# Now redirect to the mobile siteRewriteCond with this conditions  
RewriteCond %{REQUEST_URI} !^/prototypes/.* 
--> RewriteCond %{REQUEST_URI} !^/blog/.*  
--> RewriteCond %{REQUEST_URI} !^/page/.*
RewriteRule ^ http://www.applified.nl/m/web%{REQUEST_URI} [L,R]

RewriteRule ^page/([^/\.]+)/?$ ?page=$1
RewriteRule ^blog/([^/\.]+)/?$ ?page=Blog&entry=$1   [NC]
RewriteRule ^page/Blog/offset/(.+)/?$ ?page=Blog&offset=$1   [NC]

我尝试了几种方法,但我没有达成任何解决方案

干杯

1 个答案:

答案 0 :(得分:1)

将此行添加到RewriteRule

之前
RewriteCond %{REQUEST_URI} !^/page/

使用RewriteCond如果使用CondPatern前缀,您选择的!可能是不匹配的模式。 然后,如果RewriteCond为假,则不会使用后面的RewriteRule。

关于多个RewriteCond之间的关联,必须满足每个条件,以便使用后面的RewriteRule(因此它就像每个RewriteCond之间的AND,但您可以更改此行为RewriteCond末尾的[OR]标志。所以在这里你可以添加一行,它应该是开箱即用的。