2013-08-22 80 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中

相關問題