Redirecting base url only using htaccess

我怕爱的太早我们不能终老 提交于 2020-01-30 05:17:20

问题


I'd like to redirect only the base url to an external site.

For instance, I want example.com redirected to anotherdomain.com but I don't want example.com/path to be redirected.

So far, example.com/path redirects to anotherdomain.com/path. :(

EDIT :

First, thank you for the help! example.com now redirects to another.com without affecting the children paths of example.com.

However, ideally, m.example.com won't redirect to another.com. So it's really just example.com redirecting to another.com.


回答1:


Add this to your .htaccess in your DocumentRoot. I am assuming that you are hosting only one domain on the server.

RewriteEngine on
RewriteBase /

RewriteCond %{HTTP_HOST} !^m\.
RewriteRule ^$ http://anotherdomain.com [R,L]


来源:https://stackoverflow.com/questions/9418765/redirecting-base-url-only-using-htaccess

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