我已将网站移至新域名,并使用RewriteRule
重定向了一些网址。
我遇到了尝试重定向带有查询字符串的网址?
RewriteRule /news/archive.php?cat=economic-impact http://www.new-website.com/faqs/economic-impact [R=301,L]
RewriteRule /news/archive.php?cat=housing-need http://www.new-website.com/faqs/housing-need R=301,L]
RewriteRule /news/archive.php?cat=infrastructure http://www.new-website.com/faqs/infrastructure R=301,L]
进一步向上htaccess
文件我正在使用它来重定向域
RewriteEngine On
RewriteCond %{HTTP_HOST} ^old-website.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.old-website.com$
RewriteRule (.*)$ http://www.new-website.com/$1 [R=301]
当我访问时:
old-website.com/news/archive.php?cat=economic-impact
重定向到
new-website.com/news/archive.php?cat=economic-impact
我需要将哪些404重定向到:
new-website.com/faqs/economic-impact
有人可以帮忙吗?
答案 0 :(得分:0)
您需要在重写时添加空白查询字符串以截断任何现有查询字符串。
以下应该做的工作:
RewriteRule (.*)$ http://www.new-website.com/$1? [R=301]
此外,您检查现有查询字符串的方式不起作用。您需要单独检查它们:
RewriteCond %{QUERY_STRING} "cat=(economic-impact|housing-need|infrasructure)"
RewriteRule news/archive.php http://www.new-website.com/faqs/%1? R=301,L]
%1
将从RewriteCond