我已經閱讀了基於這個主題的多個線程,但沒有規則工作,所以我敢肯定我做錯了什麼。htaccess從url中刪除子目錄
我在我的/ var/WWW
main domain folders that redirects to domain.com
folder1 that redirects to domain1.com
folder2 that redirects to domain2.com
裏面以下struncture文件夾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]
htaccess的從文件夾2
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]
希望我能最後解決這個問題
你在文件夾2重寫規則沒有做任何事情:'的RewriteCond%{HTTP_HOST} domain2.com/subdirectory1'永遠不會匹配任何東西。 '%{HTTP_HOST}'只包含域部分,而不包含子目錄。 – Stobor