0

In Apache, is it possible that I can redirect a directory on my website to a new address, but keep sub-directories un-redirected?

For example, I wish to redirect accesses to files under

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

i.e. from

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

But keep the access to its sub-folders unchanged? https://www.example.com/folder/subfolder/123.html will not be redirected.

Many thanks!

4

1 回答 1

1

您可以排除子文件夹请求RewriteCond

RewriteEngine on
RewriteCond %{REQUEST_URI} !^/folder/.*?/
RewriteRule ^folder/ https://www.newexample.com%{REQUEST_URI} [R,L]
于 2013-04-30T14:47:48.817 回答