2012-02-21 84 views
0

我配置了我的htaccess来检查并将移动设备重定向到特定的网络。但我想跳过这个规则,如果REQUEST_URI是/页/ ...(博客网址)htaccess配置跳过规则

我有我的.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] 

我尝试severals的方式,但我不达成任何解决方案

干杯

回答

1

RewriteRule之前添加此行:

RewriteCond %{REQUEST_URI} !^/page/ 

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

关于几个RewriteCond之间的关联,每个条件必须得到满足,以便随后的RewriteRule使用(所以它就像一个与每个RewriteCond之间,但你可以在RewriteCond结束更改与[OR]将此行为)。所以,在这里你可以添加该行,它应该可以开箱即用。

+0

我试过这种方式,但不起作用。有可能apache服务器的配置与这个规则(或写cond)或者任何缓存mem有冲突。 (我没有访问服务器配置) – pipo02mix 2012-02-22 09:17:45