2013-08-22 77 views
1

我的.htaccess文件包含重写URL和HTTP响应状态码301 url重定向。当我测试重定向时,它将旧URL中的查询字符串值添加到重定向url的末尾。我怎样才能阻止呢?从HTTP响应状态码301中删除查询字符串url重定向

我的htaccess看起来像这样。

Options +FollowSymlinks 
Redirect 301 /old-site/tees~1-c/blue~123-p.html test.mydomain.com/tees~1-c/blue~123-p.html 
Redirect 301 /old-site/tees~1-c.html test.mydomain.com/tees~1-c.html 
Redirect 301 /old-site/content/about.html test.mydomain.com/content/about.html 

RewriteEngine on 
RewriteRule ^(.+)~(.+)-c/(.+)~(.+)-p\.html?$ product.php?cde=$1&cid=$2&pde=$3&pid=$4 [QSA] 

RewriteRule ^(.+)~(.+)-c\.html?$ category.php?cde=$1&cid=$2&ref=%3&srt=%4&sta=%5&ppa=%6 [QSA] 

RewriteRule ^content/(.+)\.html?$ info.php?seo=$1&sta=%1 [QSA] 

回答

1

截至mod_alias doc

说如果客户要求http://example.com/service/foo.txt,这将是 告诉访问http://foo2.example.com/service/foo.txt代替。这 包括用GET参数的要求,如 http://example.com/service/foo.pl?q=23&a=42,它会被重定向到 http://foo2.example.com/service/foo.pl?q=23&a=42

你可以改变你Redirec 301重写规则:

相反的:

Redirect 301 /old-site/tees~1-c/blue~123-p.html test.mydomain.com/tees~1-c/blue~123-p.html 
Redirect 301 /old-site/tees~1-c.html test.mydomain.com/tees~1-c.html 
Redirect 301 /old-site/content/about.html test.mydomain.com/content/about.html 

使用:

RewriteRule /old-site/tees~1-c.html test.mydomain.com/tees~1-c.html [L,R=301] 
RewriteRule /old-site/tees~1-c.html test.mydomain.com/tees~1-c.html [L,R=301] 
RewriteRule /old-site/content/about.html test.mydomain.com/content/about.html [L,R=301] 

如果不包含QSA标志,则不会将查询参数添加到重写的URL中

相关问题