Apache redirect from one subdomain to another

坚强是说给别人听的谎言 提交于 2019-12-02 12:13:51

Add the following RewriteRule to your VirtualHost

RewriteEngine On
RewriteCond %{HTTP_HOST} ^first.example.com$
RewriteRule ^ http://second.example.com [R=301,L]

If you wanted to redirect first.example.com/some/url to second.example.com/some/url:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^first.example.com$
RewriteRule /(.*) http://second.example.com/$1 [R=301,L]

Recommend you use [R=302] whilst testing the rules to avoid problems with 301s getting cached by your browser.

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