2015-04-27 169 views
0

我最近更改了我的网站,并将所有内容从旧域复制到新域。我拥有的旧域名是免费虚拟主机上的子域名,现在我想将所有页面重定向到新的域名。将旧子域重定向到新域

我的目标

http://old.domain.com/anything ==>http://newdomain.com


我该怎么办呢htaccess的?我已经尝试重定向,但只是主页重定向。帮助被appriciated。由于

+0

可能重复(http://stackoverflow.com/questions/1945568/试试这个htaccess的重定向的所有页面到新域) –

回答

0

你可以在你的根/的.htaccess

RedirectMatch 301 ^/(.*)/?$ http://www.newdomain.com/$1 
的[重定向的.htaccess所有页面到新的域]
0
# This will redirect a subdomain to another domain 
RewriteEngine On 
RewriteCond %{HTTP_HOST} ^old\.domain\.com$ [NC] 
RewriteRule ^(.*) http://newdomain.com/$1 [L,R]