开发者

.htaccess to restrict access by file type

I don't have too much experience with .htaccess files and I would like one that disallows access (403 Forbid开发者_如何学Pythonen) to .myext files in a folder and all its sub-folders.

Can anyone write me a quick rule?


You can use <FilesMatch> and Deny:

<FilesMatch "\.myext$">
    Deny from all
</FilesMatch>

You also might need to change the order of how Allow and Deny rules are applied.

Another option would be to use mod_rewrite:

RewriteEngine on
RewriteRule .+\.myext$ - [F]

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:

RewriteRule ^foo/bar/.+\.myext$ - [F]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜