我有这样的Apache重写规则:追加查询字符串中使用htaccess的URL重写不工作
RewriteCond %{QUERY_STRING} !lang
RewriteCond %{HTTP_HOST} ^(jp|en|kr|cn)\.example\.com
RewriteRule ^(.*)$ http://%1.example.com/$1&lang=%1 [L, QSA]
RewriteCond %{HTTP_HOST} ^(jp|en|kr|cn)\.example\.com
RewriteRule ^(.*)$ http://%1.example.com/$1?lang=%1 [L, QSA]
我的预期是什么
http://en.example.com
到http://en.example.com?lang=en
http://en.example.com/list.php
到http://en.example.com/list.php?lang=en
http://en.example.com/product.php?id=1
到http://en.example.com/product.php?id=1&lang=en
(1)和(2)是好的,但我得到了(3)是
http://en.mobile-wifi_rental.local/product.php&lang=en?id=1
。
在我情况下,它不需要是通用的。我可以使用确切的国家代码('jp | en | kr | cn')和域名('example.com')。 – Sithu
它在http://htaccess.mwl.be/尝试了您的通用规则。 'http://en.example.com/product.php?id = 1'不添加'id = 1'。结果是'http://en.example.com/product.php?lang = en'。我想要的是像'http://en.example.com/product.php?id = 1&lang = en' – Sithu
是的,我只需要一条规则,它可以在真实的现场服务器上运行,在线测试器http:// htaccess.mwl.be/不仅仅按预期工作。 – Sithu