301使用查询字符串重定向网址?

时间:2017-07-15 08:24:12

标签: .htaccess redirect mod-rewrite

我喜欢进行以下重定向:

domain.de/?file=team - > domain.de/team.html

为此,我尝试以下重写(即无效):

RewriteCond %{QUERY_STRING} ^file=team$
RewriteRule ^/$ /team.html [L,R=301]

如何进行301重定向?

1 个答案:

答案 0 :(得分:0)

我自己解决方案

RewriteCond %{QUERY_STRING} ^file=team$
RewriteRule ^$ /team.html? [L,R=301]

domain.de/?file=team - > domain.de/team.html

如果您在上面看到我的问题,我犯了以下两个错误:

<强> 1。错误:缺少问号

如果删除问号,则不会删除query_string:

RewriteRule ^$ /team.html [L,R=301]

domain.de/?file=team - &gt; domain.de/team.html?file=team

通过命令RedirectMatch无法删除query_strings的方式进一步提示。

<强> 2。错误:错误的重写路径

 RewriteRule ^\$ ... does not match doamin.de/?file=team
 RewriteRule ^$ ... matches