多个 RewriteCond 用于多个 RewriteRules

发布于 2024-11-10 23:04:33 字数 728 浏览 0 评论 0原文

我正在使用这些重写规则,这些规则仅在没有“用户”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 条规则。

I'm using these rewrite rules that only go into effect if there is NOT a "user" 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]

Now, how can I add another condition that there must not be a query string value? If there is a "user" cookie OR a query string, those 5 rules should be skipped.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

再见回来 2024-11-17 23:04:33
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]
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]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文