我有两个网站,可以给他们打电话example.com和example2.com。
I've got two sites, lets call them example.com and example2.com.
用于该网站只能通过example.com访问,但我们的客户希望改变,因此,他们注册example2.com他们的名字。现在example.com且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.
我需要一个htaccess规则,将引导所有流量通过旧域example.com访问该网站,301重定向到新的域名example2.com。
I need an htaccess rule that will direct all traffic accessing the site via the old domain example.com and 301 redirect it to the new domain example2.com.
我知道这是怎么回事包括至少一个REWRITE_COND,但我不知道是什么语法我需要的。
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]
上一篇:与路线和mod-rewrite(如果没有绝对的我不明白的CSS,JS或图像)问题我不、如果没有、图像、路线
下一篇:如何使无需手动添加有路径`/一些-DIR /`或`的RewriteBase /一些-dir`此的.htaccess规则做工精细?做工、路径、精细、规则