.htaccess 如何使用htaccess将查询字符串附加到url

.htaccess 如何使用htaccess将查询字符串附加到url,.htaccess,url-rewriting,.htaccess,Url Rewriting,我想根据用户代理将查询字符串附加到我的所有URL 例如:xyz.com/buy.html到xyz.com/buy.html?eq=mobile` xyz.com/more/buy.htmltoxyz.com/more/buy.html?eq=mobile #RewriteCond %{HTTP_USER_AGENT} "android|blackberry|googlebot-mobile|iemobile|ipad|iphone|ipod|opera mobile|palmos|webos"

我想根据用户代理将查询字符串附加到我的所有URL

例如:xyz.com/buy.html
xyz.com/buy.html?eq=mobile`

xyz.com/more/buy.html
to
xyz.com/more/buy.html?eq=mobile

#RewriteCond %{HTTP_USER_AGENT} "android|blackberry|googlebot-mobile|iemobile|ipad|iphone|ipod|opera mobile|palmos|webos" [NC] 

正在检测移动浏览器,但无法写入正确的
重写规则

您需要确保查询字符串不存在:

RewriteCond %{HTTP_USER_AGENT} "android|blackberry|googlebot-mobile|iemobile|ipad|iphone|ipod|opera mobile|palmos|webos" [NC] 
RewriteCond %{QUERY_STRING} !^eq=mobile
RewriteRule ^(.*)$ $1?eq=mobile [L,QSA]

我试过这个,但不起作用。移动和桌面的URL保持不变