Using htaccess to redirect a directory, but not the files in it

那年仲夏 提交于 2019-12-31 04:41:08

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!