如何使用相同的URL路径将一个URL重定向到另一个URL

时间:2016-02-24 19:12:42

标签: php .htaccess dns

所以基本上我有2个域名,domain1.com和domain2.com

对于domain2.com,我想将其重定向到domain1.com并保持其余的URL路径不变。

例如:

domain2.com/same/url/path会重定向到 domain1.com/same/url/path

我该怎么做?

1 个答案:

答案 0 :(得分:1)

domain2的网站root .htaccess中使用此规则:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(?:www\.)?domain2\.com$ [NC]
RewriteRule ^ http://domain1.com%{REQUEST_URI} [R=301,L,NE]
相关问题