2012-02-21 158 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