2013-04-30 154 views
0

在Apache中,我可以將我的網站上的目錄重定向到新地址,但保持子目錄未重定向?Apache,重定向目錄但保留子目錄未重定向

例如,我想訪問重定向到文件下

https://www.example.com/folder/ to 
https://www.newexample.com/folder/ 

即從

https://www.example.com/folder/abc.html to 
https://www.newexample.com/folder/abc.html 

但保留訪問其子文件夾不變? https://www.example.com/folder/subfolder/123.html不會被重定向。

非常感謝!

回答

1

您可以排除與RewriteCond

RewriteEngine on 
RewriteCond %{REQUEST_URI} !^/folder/.*?/ 
RewriteRule ^folder/ https://www.newexample.com%{REQUEST_URI} [R,L] 
+0

這是輝煌的,就像一個魅力的子文件夾的請求。非常感謝Dietsche。 – user2336206 2013-05-02 10:40:14