htaccess RewriteRule 阻止 php/html,允许所有其他...?

发布于 2024-10-01 05:26:40 字数 74 浏览 0 评论 0原文

如何为 htaccess 编写 RewriteRule 以阻止对 php/html 的访问(除非经过身份验证)并允许访问所有其他扩展?

How do I write a RewriteRule for htaccess to block access to php/html (unless authenticated) and allow access to all other extensions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

卖梦商人 2024-10-08 05:26:40

您应该能够将标准 .htpassword auth 放入 filesmatch 属性中...

所以...

<FilesMatch "\.(html|php)$">
AuthName "Private zone"
AuthType Basic
AuthUserFile .htpasswd
require valid-user
</FilesMatch>

这应该会导致对 .html 或 .php 的任何请求要求输入密码,您必须生成有效的 .htpasswd 文件...

You should be able to put a standard .htpassword auth inside a filesmatch attribute...

So...

<FilesMatch "\.(html|php)$">
AuthName "Private zone"
AuthType Basic
AuthUserFile .htpasswd
require valid-user
</FilesMatch>

That should cause any request to .html or .php to ask for a password, you must generate a valid .htpasswd file...

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