Redirect Website Homepage Only

社会主义新天地 提交于 2021-02-18 22:52:18

问题


I have two different websites that are hosted on different servers. I would like to redirect the homepage of the old site (www.oldsite.com.au) to the homepage of the new site (newsite.com.au). However, I do not want any pages within the old site (www.oldsite.com.au/page) to redirect to the new one (newsite.com.au/page). So, www.oldsite.com.au must redirect to newsite.com.au, but any other pages or files within the old site must not redirect.

All the .htaccess ideas I've tried just redirect every file from the old site to the new one.


回答1:


Try one of these:

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

or

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

If you don't want a 301 (permanent) redirect, remove the 301 from the RedirectMatch or the =301 from the square brackets in the rule's flags.



来源:https://stackoverflow.com/questions/31281346/redirect-website-homepage-only

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!