【问题标题】:Redirect 301 in link在链接中重定向 301
【发布时间】:2014-05-09 12:55:58
【问题描述】:
我想为地址设置重定向 301:
http://example.com/?test=123sdf
到:
http://example.com/
我该怎么做?我试试:
Redirect 301 /?test=123sdf http://example.com/
但这不起作用。我想在我的 .htaccess 文件中添加这个。
【问题讨论】:
标签:
php
apache
.htaccess
redirect
web
【解决方案1】:
RewriteRule 仅将 REQUEST_URI 与查询字符串匹配。您将需要 RewriteCond 来匹配查询。将此代码放入您的 DOCUMENT_ROOT/.htaccess 文件中:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^test=123sdf$ [NC]
RewriteRule ^$ /? [L,R=301]
【解决方案2】:
你可以使用;
RewriteEngine on
RewriteRule ^test=123sdf$ / [R=301]