2013-04-30 145 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