.htaccess 按文件类型限制访问
我对 .htaccess 文件没有太多经验,我想要一个禁止访问(403 Forbiden)文件夹及其所有子文件夹中的 .myext
文件的文件。
谁能给我写一个快速规则吗?
I don't have too much experience with .htaccess files and I would like one that disallows access (403 Forbiden) to .myext
files in a folder and all its sub-folders.
Can anyone write me a quick rule?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
和拒绝
:您可能还需要更改的顺序<应用 code>Allow 和
Deny
规则。另一种选择是使用 mod_rewrite:
仅应用这些指令对于特定目录,将它们放入该特定目录的 .htaccess 文件中。使用 mod_rewrite 您还可以在规则模式中指定路径,例如:
You can use
<FilesMatch>
andDeny
:You also might need to change the order of how
Allow
andDeny
rules are applied.Another option would be to use mod_rewrite:
To have these directives only be applied on specific directories, put them into the .htaccess file of that specific directory. With mod_rewrite you could also specify the path within the rule pattern like: