我已经重写的.htaccess的URL,所以它看起来prettier。 但是,当我这个网址后添加查询字符串,键和值将不会被发现!
没有人也遇到过这个问题?
在我的.htaccess文件,我试过几件事情来解决这个问题,但是毫无效果。
RewriteEngine叙述上
[约code]
重写规则^([A-ZA-Z0-9 _-] +)/?$?网站= $ 1
我已经试过这种重写,来看看它是否工作:
重写规则^搜Q = G =网站搜索和放大器;] Q = G
但是,如果我的print_r($ _ GET)
在PHP中,我只是让阵列([现场] =>搜索)
尝试在 http://kwtsports.bplaced.de/search?q=g 。
我有一个重定向到/搜索Q = blablaSearchQuery,但我怎么说,在 $ _ GET ['Q']
是空的。
这也不起作用:
重写规则^搜Q =(A-ZA-Z0-9 _-] +)/ $网站=搜索和;???Q = $ 1
有谁知道,为什么会这样?
解决方案 [QSA]
添加到您的结束重写规则
。这追加旧的查询字符串的结果。
请参见文档以获取更多信息。
I have rewritten a URL with .htaccess so it looks prettier. But when I add a query string after this URL, the keys and values won't be observed!
Did anyone experienced this problem?
In my .htaccess file, I tried several things to fix the problem, but nothing worked.
RewriteEngine On
[some code]
RewriteRule ^([a-zA-Z0-9_-]+)/?$ ?site=$1
I have tried this rewriting, to see if it works:
RewriteRule ^search?q=g ?site=search&q=g
But if I print_r($_GET)
in PHP, I will just get Array ( [site] => search )
Try it on http://kwtsports.bplaced.de/search?q=g.
I have a search field that redirects to /search?q=blablaSearchQuery, but how I said, the $_GET['q']
is empty.
This also doesn't work:
RewriteRule ^search?q=([a-zA-Z0-9_-]+)/?$ ?site=search&q=$1
Does anyone know, why this happens?
解决方案Add [QSA]
to the end of your RewriteRule
. This appends the old query string to the result.
See the docs for more information.
上一篇:Ridirecting到一个站点时,有一个?(问号)的网址是什么?问号、有一个、站点、网址
下一篇:如何使用Htacess的www.example.com/type.php?user=name如何使用、www、example、com