重定向带有查询字符串 ?donotcache=1 的 URL,适用于 UserAgent Android



我想将所有页面从静态页面重定向到 donotcache=1 页面这是我的代码

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} "Android" [NC]
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}?donotcache=1 [R=302,L]
</IfModule>

但代码不起作用。

工作代码

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} "Android" [NC]
RewriteCond %{QUERY_STRING} ^$ [NC]
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI}$1?donotcache=1 [R=302,L]
</IfModule>

最新更新