在.htaccess文件中重定向301,但仍然是同一页面?

时间:2014-05-03 13:20:06

标签: apache .htaccess redirect

这种重定向有什么不对?

Redirect 301 /?p=byggnad&id=31 http://domainname.com

这可行,但随后整个网站被重定向。我想重新定位网站上的sime页面。

Redirect 301 / http://domainname.com

我是否错过了堡垒重定向中的某些内容?

2 个答案:

答案 0 :(得分:0)

您可以使用'标题'重定向,代码在下面。

标题("位置:http://domainname.com/?p=byggnad&id=31",true,301); 出口();

答案 1 :(得分:0)

Redirect 301 /?p=byggnad&id=31 http://domainname.com

不正确,无法使用,因为您无法使用Redirect指令匹配查询字符串。您需要使用基于mod_rewrite的规则:

RewriteEngine On

RewriteCond %{QUERY_STRING} ^p=byggnad&id=31$
RewriteRule ^$ http://domainname.com/? [L,R=301]
最后

?用于去除任何现有的查询字符串。