.htaccess htaccess重写规则保留查询字符串
我有这样一条规则:.htaccess htaccess重写规则保留查询字符串,.htaccess,mod-rewrite,.htaccess,Mod Rewrite,我有这样一条规则: RewriteRule ^thesection$ /sections.php [L] RewriteRule ^thesection/(.*)$ /sections.php?show=$1 [L] 因此,如果我进入domain.com/thesection->,它的工作效果会非常好 但是!,如果我输入domain.com/thesection/hello它将重定向到domain.com/thesection?show=hello 我不知道我做错了什么,我花了几个小时在谷歌上
RewriteRule ^thesection$ /sections.php [L]
RewriteRule ^thesection/(.*)$ /sections.php?show=$1 [L]
因此,如果我进入domain.com/thesection
->,它的工作效果会非常好
但是!,如果我输入domain.com/thesection/hello
它将重定向到domain.com/thesection?show=hello
我不知道我做错了什么,我花了几个小时在谷歌上搜索。请帮忙
提前谢谢试试这个,让我知道
RewriteEngine On
RewriteRule ^thesection/?$ /sections.php [L,QSA]
RewriteRule ^thesection/([a-z0-9\-_]+)/?$ /sections.php?show=$1 [L,QSA]
这将把domain.com/thesection/hello
重定向到sections.php?show=hello
QSA标志意味着:
此标志强制重写引擎将查询字符串附加到
将替换字符串替换为现有字符串,而不是替换
信息技术如果要通过
重写规则
因此,您可以添加更多参数,例如:http://www.domain.com/thesection/hello/?page=1
这将输出:
Array (
[show] => hello
[page] => 1
)
什么是
domain.com/thesection/hello
应该被重写到?Hi Jon,domain.com/thesection/hello应该被服务器解释为domain.com/sections.php?show=hello谢谢!我不知道我做错了什么,但那没用。如果我输入domain.com/thesection/hello,我的浏览器将重定向到domain.com/thesection?show=hello,这不是我见过的最漂亮的url:(无论如何,谢谢你,我今天学到了很多。对不起,我的错。我有一个配置错误。这非常有效,谢谢!