仅重定向网站主页

时间:2015-07-07 23:53:27

标签: .htaccess redirect

我有两个不同的网站托管在不同的服务器上。我想将旧网站的主页(www.oldsite.com.au)重定向到新网站的主页(newsite.com.au)。但是,我希望旧网站(www.oldsite.com.au/page)中的任何网页重定向到新网站(newsite.com.au/page)。因此,www.oldsite.com.au必须重定向到newsite.com.au,但旧网站中的任何其他页面或文件都不得重定向。

我尝试过的所有.htaccess想法只是将旧网站中的每个文件重定向到新网站。

1 个答案:

答案 0 :(得分:9)

尝试以下方法之一:

RedirectMatch 301 ^/$ http://newsite.com.au/

RewriteEngine On
RewriteRule ^$ http://newsite.com.au/ [L,R=301]

如果您不想要301(永久)重定向,请从RedirectMatch中删除301,或从规则标志中的方括号中删除=301

相关问题