.htaccess RewriteRule 保留 GET URL 参数
我在 .htaccess
URL 重写后保持 URL 参数正常工作时遇到问题。
我的 .htaccess
重写如下:
RewriteEngine on
RewriteRule ^([a-z]{2,2})/([a-zA-Z0-9_-]+)$ index.php?lang=$1&page=$2
这意味着:
example.com/index.php?lang=en&page=product
显示为 example.com/en /product
由于某种原因,当我在 URL 末尾添加 ?model=AB123&color=something
时,我无法使用 $ 在 PHP 中检索这些参数_GET['model']
和 $_GET['color']
即使它们出现在显示的 URL 中。
为什么变量不被传递?
I'm having issues keeping the parameters of the URL working after an .htaccess
URL rewrite.
My .htaccess
rewrite is as follows:
RewriteEngine on
RewriteRule ^([a-z]{2,2})/([a-zA-Z0-9_-]+)$ index.php?lang=$1&page=$2
Which means:
example.com/index.php?lang=en&page=product
displays as example.com/en/product
For some reason, when I add a ?model=AB123&color=something
at the end of my URLs I am not able to retrieve those parameters in PHP using $_GET['model']
and $_GET['color']
even though they are present in the displayed URL.
Why aren't the variables passed along?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要附加 [QSA](查询字符串附加)标签。尝试
参见http://httpd.apache.org/docs/2.2/mod/mod_rewrite .html
You need to append with the [QSA] (query string append) tag. Try
See http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html