Несколько RewriteCond для нескольких RewriteRules - PullRequest
1 голос
/ 30 мая 2011

Я использую эти правила перезаписи, которые вступают в силу только в том случае, если НЕ существует «пользовательский» cookie.

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 правил следует пропустить.

1 Ответ

2 голосов
/ 30 мая 2011
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]
...