[英]htaccess redirect entire domain/folder to another domain
我不是htaccess的朋友,遇到了我似乎无法用Google解决的问题。 因此,希望你们能提供帮助。
我在那里,我想所有重定向到TRAFIC一个mydomain.com/anothersite多站点安装目录(和所有子文件夹和查询字符串),以anothersite.com,并在同一时间必须anothersite.com重写所有请求请求服务器查找anothersite文件夹。
基本上,服务器文件夹设置如下:在根,我们有我们有一个文件夹“anothersite”根网站包含其他网站
因此,对mydomain.com的所有请求都应显示根文件夹,而对anothersite.com的所有请求应被重写。
希望有道理
这是我所拥有的(它几乎可以正常工作,但是效果不佳)
RewriteEngine on
RewriteBase /
RewriteRule ^mydomain\.com/anothersite(.*)$ http://anothersite.com/$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^(www.)?anothersite.com$
RewriteRule !^anothersite/ anothersite%{REQUEST_URI} [L]
问题在于,对mydomain.com/anothersite/someFolderOrQuerystring的请求未重定向,而mydomain.com/anothersite/
希望有道理
(顺便说一句:如果有人可以将我指向一本书的方向,那将使我成为htaccess文件奥秘的主人,这将是可喜的收获。
在网站根目录.htaccess中有以下规则:
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www\.)?mydomain\.com$ [NC]
RewriteRule ^anothersite(/.*)?$ http://anothersite.com%{REQUEST_URI} [NE,L,R=301]
RewriteCond %{HTTP_HOST} ^(www\.)?anothersite\.com$ [NC]
RewriteRule !^anothersite/ anothersite%{REQUEST_URI} [L,NC]
确保您在anothersite/
文件夹下没有任何.htaccess。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.