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]
精彩评论