问题描述
我想写一个.htaccess线,将重写PHP脚本,但仍允许在结束时添加任何额外的GET变量。这可能吗?
目前我试图用这样的:
重写规则^项/([^ /] *)([^ /] *)$ /item.php?id=$1&$2 [L]
这样做的目的是为了能够做的事情一样 blah.com/item/foo
,而且 blah.com/item/foo?巴=什么
。
目前它似乎正确地传递的第一部分, ID
,而不是休息。
重写规则^项/([^ /] *)([^ /] *)$ /item.php? ID = $ 1安培; $ 2 [L,QSA]
您可以阅读更多关于 QSA
(查询字符串追加)在这里:https://httpd.apache.org/docs/2.0/mod/mod_rewrite.html
I'm trying to write an .htaccess line that will rewrite to a php script but still allow any extra get variables to be added on the end. Is this possible?
Currently I'm trying to use this:
RewriteRule ^item/([^/]*)([^/]*)$ /item.php?id=$1&$2 [L]
The aim is to be able to do things like blah.com/item/foo
, but also blah.com/item/foo?bar=whatever
.
Currently it seems to correctly pass the first part, id
, but not the rest.
RewriteRule ^item/([^/]*)([^/]*)$ /item.php?id=$1&$2 [L,QSA]
You can read more about QSA
(query string append) here:https://httpd.apache.org/docs/2.0/mod/mod_rewrite.html
这篇关于的.htaccess改写pretty的网址仍然可以使用GET变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!