在链接中重定向301

时间:2014-05-09 12:55:59

标签: php apache .htaccess redirect web

我想为地址重定向301:

http://example.com/?test=123sdf

为:

http://example.com/

我怎么做到的?我试试:

Redirect 301 /?test=123sdf http://example.com/

但这不起作用。我想在我的.htaccess文件中添加它。

2 个答案:

答案 0 :(得分:1)

RewriteRule仅将REQUEST_URI与查询字符串匹配。您需要RewriteCond来匹配查询。将此代码放在DOCUMENT_ROOT/.htaccess文件中:

RewriteEngine On

RewriteCond %{QUERY_STRING} ^test=123sdf$ [NC]
RewriteRule ^$ /? [L,R=301]

答案 1 :(得分:0)

你可以使用;

RewriteEngine on
RewriteRule ^test=123sdf$ / [R=301]
相关问题