问题
On my website, I've got a directory /folder with some images and html in it. I want to redirect users who try to access http://domain.com/folder to http://domain.com/ but don't want requests for the files in that directory to redirect to http://domain.com/ either. When I try
Redirect /folder http://domain.com/
it breaks the site because now it thinks all the images, etc are in the root directory when it is not. How do i fix this?
回答1:
Use RedirectMatch instead:
RedirectMatch ^/folder$ http://example.com/
Now the URI path must exactly match /folder.
来源:https://stackoverflow.com/questions/4298255/using-htaccess-to-redirect-a-directory-but-not-the-files-in-it