在它使用的htaccess重定向一个目录,但不会生成文件重定向、文件、目录、htaccess

2023-09-02 00:30:49 作者:旧城旧梦旧情人。

在我的网站,我有一个目录/文件夹的一些图像和HTML在里面。我想将用户重定向谁试图访问 http://domain.com/folder 到的 http://domain.com/ ,但不希望在该目录中的文件的请求重定向到的 http://domain.com/ 无论是。当我尝试

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?

推荐答案

使用的 RedirectMatch 来代替:

Use RedirectMatch instead:

RedirectMatch ^/folder$ http://example.com/

现在的URI路径必须完全匹配 /文件夹

Now the URI path must exactly match /folder.