RewriteRule:拒绝除 root、文件和特定文件夹中的所有文件之外的所有内容
我想否认一切;但应允许以下情况:
1 http://example.com/
2 http://example.com/favicon.ico
3 http://example.com/downloads/secret/test.txt
通过
RewriteEngine On
RewriteRule !^(favicon\.ico|downloads/secret/[^/]+\.[a-z]+)?$ - [F,L]
数字 2 和 3 工作得很好。但我无法访问 http://example.com/
如何修改我的 RewriteRule 以使第一个示例正常工作还有?
I'd like to deny everything; except the following should be allowed:
1 http://example.com/
2 http://example.com/favicon.ico
3 http://example.com/downloads/secret/test.txt
via
RewriteEngine On
RewriteRule !^(favicon\.ico|downloads/secret/[^/]+\.[a-z]+)?$ - [F,L]
Number 2 and 3 work just fine. But I can't reach http://example.com/
How do I modifiy my RewriteRule to make the first example work as well?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
添加以下内容:
将
index.php
更改为您正在使用的索引文件(例如index.html
、index.pl
等)Add this:
change
index.php
to what ever index file you are using (likeindex.html
,index.pl
etc)