RewriteRule:拒绝除 root、文件和特定文件夹中的所有文件之外的所有内容

发布于 2025-01-07 01:28:38 字数 416 浏览 2 评论 0原文

我想否认一切;但应允许以下情况:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

呢古 2025-01-14 01:28:38

添加以下内容:

RewriteEngine on
RewriteCond %{REQUEST_URI} !^/(?:|favicon\.ico|downloads/secret/test\.txt|index.php)$
RewriteRule ^ - [F]

index.php 更改为您正在使用的索引文件(例如 index.htmlindex.pl 等)

Add this:

RewriteEngine on
RewriteCond %{REQUEST_URI} !^/(?:|favicon\.ico|downloads/secret/test\.txt|index.php)$
RewriteRule ^ - [F]

change index.php to what ever index file you are using (like index.html, index.pl etc)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文