使用 htaccess 重定向目录,但不重定向其中的文件
在我的网站上,我有一个目录 /folder,其中包含一些图像和 html。我想将尝试访问 http://domain.com/folder 的用户重定向到 http://domain.com/ 但不希望对该目录中的文件的请求重定向到 http://domain.com/ 之一。当我尝试时,
Redirect /folder 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
RedirectMatch
相反:现在 URI 路径必须与
/folder
完全匹配。Use
RedirectMatch
instead:Now the URI path must exactly match
/folder
.