在它使用的htaccess重定向一个目录,但不会生成文件 [英] Using htaccess to redirect a directory, but not the files in it

查看:206
本文介绍了在它使用的htaccess重定向一个目录,但不会生成文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的网站,我有一个目录/文件夹的一些图像和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.

这篇关于在它使用的htaccess重定向一个目录,但不会生成文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆