[英]Redirect url and mask domain using htaccess
我正在尝试进行一些调整,以便能够在1个主机中容纳2个域,但我缺少的是-无法掩盖地址栏中的网址。 那是我的意思:我有2个域-位于/(根)目录中的test1.com和test2.com test1.com和位于/ subdir /中的test2内容
我使用htaccess重定向301将所有请求从test2.com重定向到/ subdir /:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^test2.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.test2.com$
RewriteRule (.*)$ http://test1.com/subdir/ [R=301,L]
</IfModule>
那工作正常,但是我输入的地址是: http : //test1.com/subdir/我如何屏蔽/重写此地址url,使其显示为http://test2.com ?
您可以尝试以下规则:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?test2\.com$ [NC]
RewriteRule ^(index\.php)?$ /test2.com/index.html [NC,L]
RewriteCond %{REQUEST_URI} !\.(css|js|jpe?g|gif|bmp|png|tiff|ico)$ [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?test2\.com$ [NC]
RewriteRule !^(test2\.com|stylesheets|js)/ /test2.com%{REQUEST_URI} [NC,L,NE]
</IfModule>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.