0

我已经阅读了基于这个主题的多个线程,但没有任何规则有效,所以我确定我做错了什么。

我的 /var/www 中有以下结构

main domain folders that redirects to domain.com
folder1 that redirects to domain1.com
folder2 that redirects to domain2.com

在文件夹 2 中,我还有 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:一个在根文件夹内,一个在文件夹 2 内

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]

来自文件夹 2 的 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]

希望我终于可以解决这个问题

4

1 回答 1

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]
于 2012-06-23T21:06:01.717 回答