我在找重定向的每个页面旧域到单页在新的领域。它也应该重定向无论是www和非www版本。每一个请求域old,无论是什么,应该引起www.new根。
I'm looking to redirect each and every page on the old domain to a single page on the new domain. It should also redirect both the www and non-www versions. Every single request to the domain old, whatever it may be, should lead to www.new root.
old/1.php www.old/2.php old/2.php old/links/index.php old/about-us.html old/?string=1
都应该重定向到:
should all redirect to:
www.new /
www.new/
我正在寻找一个解决方案的.htaccess
I'm looking for a .htaccess solution.
推荐答案您可以在old虚拟主机使用RedirectMatch
You can use RedirectMatch in the old vhost
RedirectMatch permanent .* www.new/
重定向追加匹配的URI来重定向结尾部分URI,但 RedirectMatch 这是由你来选择您想要使用圆括号来转移部分(如有)及 $号引用。
Redirect appends the trailing portion of the matched URI to the redirection URI but with RedirectMatch it's up to you to choose the parts (if any) that you want to transfer using parentheses and $number references.
如果旧的和新的领域必须是别名磁盘上的同一个文档根目录,那么你可能需要使用mod_rewrite
If the old and new domains must be aliases for the same document root on disk then you'll probably have to use mod_rewrite
RewriteEngine on RewriteCond %{HTTP_HOST} old\$ RewriteRule .* www.new/ [L,R=301]更多推荐
的.htaccess 301重定向旧域的所有网页上的新域单页
发布评论