开发者

Redirect One domain to another on the same IP

I've got two sites, lets call them example.com and example2.com.

The website used to only be accessible via example.com but our client wanted to change their name so they registered example2.com. Now example.com and example2.com are now pointing to the same website.

I need an htaccess rule that will direct al开发者_如何转开发l traffic accessing the site via the old domain example.com and 301 redirect it to the new domain example2.com.

I know it's going involve at least one REWRITE_COND but I don't know what syntax I need.


Nevermind, I figured it out. Here's my solution:

# Redirect Traffic from old domain
RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteRule (.*) http://www.example2.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^example\.com$
RewriteRule (.*) http://www.example2.com/$1 [R=301,L]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜