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


How to make one URL redirect to another with the same URL path

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

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

例如:

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

我该怎么做?

domain2的网站根目录 .htaccess 中使用此规则:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(?:www'.)?domain2'.com$ [NC]
RewriteRule ^ http://domain1.com%{REQUEST_URI} [R=301,L,NE]