2011-05-30 194 views
1

我正在使用這些只有在沒有「用戶」cookie的情況下才會生效的重寫規則。Multiple RewriteCond for multiple RewriteRules

RewriteCond %{HTTP_COOKIE} (user) 
RewriteRule (.*)? - [S=5] # Skip the below 5 lines if the above test passes 
RewriteRule ^$ app/webroot/cache_static_html/cache_static_popular_results_1.html [L] 
RewriteRule ^popular/page:2$ app/webroot/cache_static_html/cache_static_popular_results_2.html [L] 
RewriteRule ^popular/page:3$ app/webroot/cache_static_html/cache_static_popular_results_3.html [L] 
RewriteRule ^popular/page:4$ app/webroot/cache_static_html/cache_static_popular_results_4.html [L] 
RewriteRule ^popular/page:5$ app/webroot/cache_static_html/cache_static_popular_results_5.html [L] 

現在,我該如何添加另一個條件,一定不能有查詢字符串值?如果有「用戶」cookie或查詢字符串,則應跳過這5條規則。

回答

2
RewriteCond %{HTTP_COOKIE} (user) [OR] 
RewriteCond %{QUERY_STRING} ^user=(.*) #assuming ?user=xyz 
RewriteRule (.*)? - [S=5] # Skip the below 5 lines if the above test passes 
RewriteRule ^$ app/webroot/cache_static_html/cache_static_popular_results_1.html [L] 
RewriteRule ^popular/page:2$ app/webroot/cache_static_html/cache_static_popular_results_2.html [L] 
RewriteRule ^popular/page:3$ app/webroot/cache_static_html/cache_static_popular_results_3.html [L] 
RewriteRule ^popular/page:4$ app/webroot/cache_static_html/cache_static_popular_results_4.html [L] 
RewriteRule ^popular/page:5$ app/webroot/cache_static_html/cache_static_popular_results_5.html [L]