[英]Redirect all traffic to root of another domain
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
.我想将所有内容从
http://www.old.com/
重定向到http://www.new.com/
,无论用户试图在www.old.com
上访问哪个页面。
Doing this:这样做:
RewriteEngine on
Redirect 301 / http://www.new.com/
is fine for the root, but other pages would do this:对 root 来说没问题,但其他页面会这样做:
http://www.old.com/cms -> http://www.new.com/cms
whereas I'd want it to go to the root, no matter what.而无论如何,我都希望它进入根部。
From http://www.webconfs.com/how-to-redirect-a-webpage.php I'd say you can use the following configuration从http://www.webconfs.com/how-to-redirect-a-webpage.php我会说你可以使用以下配置
Don't redirect subfolders/files (as you wanted): www.example.com/demo/ -> www.newexampledomain.com不要重定向子文件夹/文件(如您所愿):www.example.com/demo/ -> www.newexampledomain.com
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.newdomain.com/ [R=301,L]
Redirect to subfolders/files: www.example.com/demo/ -> www.newexampledomain.com/demo/重定向到子文件夹/文件:www.example.com/demo/ -> www.newexampledomain.com/demo/
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]
Put this code in your ROOT .htaccess on www.old.com
将此代码放在
www.old.com
上的 ROOT .htaccess 中
Options +FollowSymLinks -MultiViews
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?old\.com$ [NC]
RewriteRule ^ http://www.new.com/ [R=301,L]
This rule will externally redirect all www.old.com/*
to www.new.com/
此规则会将所有
www.old.com/*
外部重定向到www.new.com/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.