我已根据这个主题阅读了多个主题,但没有一个规则有效,所以我确定我做错了。
我的/ var / www
中有以下针灸main domain folders that redirects to domain.com
folder1 that redirects to domain1.com
folder2 that redirects to domain2.com
在folder2中我还有3个子目录
folder2/subdirectory1
folder2/subdirectory2
folder2/subdirectory3
这些应重定向到:
www.domain2.com/subdirectory1
www.domain2.com/subdirectory2
www.domain2.com/subdirectory3
但不是这样,它还在url中显示了folder2,因此它列出了
www.domain2.com/folder2/subdirectory1
www.domain2.com/folder2/subdirectory2
www.domain2.com/folder2/subdirectory3
我有两个.htaccess:一个位于根文件夹内,另一个位于folder2
内来自根文件夹的htaccess
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
ReWriteCond %{HTTP_HOST} domain1.com
ReWriteCond %{REQUEST_URI} !folder1/
ReWriteRule ^(.*)$ folder1/$1 [L]
ReWriteCond %{HTTP_HOST} domain2.com
ReWriteCond %{REQUEST_URI} !folder2/
ReWriteRule ^(.*)$ folder2/$1 [L]
来自folder2的htaccess
RewriteEngine On
RewriteBase /
ReWriteCond %{HTTP_HOST} domain2.com/subdirectory1
ReWriteCond %{REQUEST_URI} !subdirectory1/
ReWriteRule ^(.*)$ subdirectory1/$1 [L]
ReWriteCond %{HTTP_HOST} domain2.com/subdirectory2
ReWriteCond %{REQUEST_URI} !subdirectory2/
ReWriteRule ^(.*)$ subdirectory2/$1 [L]
ReWriteCond %{HTTP_HOST} domain2.com/subdirectory3
ReWriteCond %{REQUEST_URI} !subdirectory3/
ReWriteRule ^(.*)$ subdirectory3/$1 [L]
希望我能最终解决这个问题
答案 0 :(得分:0)
我认为您应该将重定向代码[R]
用于folder2 .htaccess
RewriteRule
。
这样:
RewriteEngine On
RewriteBase /
ReWriteCond %{HTTP_HOST} domain2.com/subdirectory1
ReWriteCond %{REQUEST_URI} !subdirectory1/
ReWriteRule ^(.*)$ subdirectory1/$1 [R]
ReWriteCond %{HTTP_HOST} domain2.com/subdirectory2
ReWriteCond %{REQUEST_URI} !subdirectory2/
ReWriteRule ^(.*)$ subdirectory2/$1 [R]
ReWriteCond %{HTTP_HOST} domain2.com/subdirectory3
ReWriteCond %{REQUEST_URI} !subdirectory3/
ReWriteRule ^(.*)$ subdirectory3/$1 [R]