将所有流量重定向到另一个域的根 [英] Redirect all traffic to root of another domain
问题描述
我有一个不再使用的域.我想将所有内容从 http://www.old.com/
重定向到 http://www.new.com/
,无论用户尝试访问哪个页面访问 www.old.com
.
I have a domain that's not to be used anymore. I want to redirect all from http://www.old.com/
to http://www.new.com/
, no matter what page the user's attempted to access on www.old.com
.
这样做:
RewriteEngine on
Redirect 301 / http://www.new.com/
对于根来说很好,但其他页面会这样做:
is fine for the root, but other pages would do this:
http://www.old.com/cms ->http://www.new.com/cms
而无论如何我都希望它进入根目录.
whereas I'd want it to go to the root, no matter what.
推荐答案
来自 http://www.webconfs.com/how-to-redirect-a-webpage.php 我想你可以使用以下配置
From http://www.webconfs.com/how-to-redirect-a-webpage.php I'd say you can use the following configuration
不要重定向子文件夹/文件(如您所愿):www.example.com/demo/-> www.newexampledomain.com
Don't redirect subfolders/files (as you wanted): www.example.com/demo/ -> www.newexampledomain.com
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.newdomain.com/ [R=301,L]
重定向到子文件夹/文件:www.example.com/demo/-> www.newexampledomain.com/demo/
Redirect to subfolders/files: www.example.com/demo/ -> www.newexampledomain.com/demo/
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]
这篇关于将所有流量重定向到另一个域的根的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!