的.htaccess重写规则,以preserve GET URL参数 [英] .htaccess RewriteRule to preserve GET URL parameters

查看:300
本文介绍了的.htaccess重写规则,以preserve GET URL参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有保持URL的htaccess的URL重写后的工作参数的问题。

I'm having issues keeping the parameters of the url working after an htaccess url rewrite.

我的htaccess重写如下:

My htaccess rewrite is as follows:

 RewriteEngine on
 RewriteRule ^([a-z]{2,2})/([a-zA-Z0-9_-]+)$ index.php?lang=$1&page=$2

这意味着:

domain.com/index.php?lang=en&page=product domain.com/en/product

由于某些原因,当我加入模式= AB123和放大器;颜色=东西在我的网址结束,我无法检索PHP中使用这些参数< $ C C> $ $ _ GET ['模型'] $ _ GET ['色'] ,即使他们是present在显示的URL。

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?

推荐答案

您需要追加的[QSA(查询字符串追加)标签。尝试

You need to append with the [QSA] (query string append) tag. Try

RewriteEngine on
RewriteRule ^([a-z]{2,2})/([a-zA-Z0-9_-]+)$ index.php?lang=$1&page=$2 [QSA]

请参阅<一href="http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html">http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html

这篇关于的.htaccess重写规则,以preserve GET URL参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆