Its been a long time since I've needed to crack open an .htaccess file...
What is the simplest way to 40x prevent access to a specific file extension though out the entire site?
Its been a long time since I've needed to crack open an .htaccess file...
What is the simplest way to 40x prevent access to a specific file extension though out the entire site?
<FilesMatch "\.ext$">
Deny from all
</FilesMatch>
See the Apache documentation on FilesMatch and Deny
EDIT: Artefacto makes a good point, this will return 403, not 404, if that's important for your purposes
<FilesMatch "\.(htaccess|htpasswd|ini|log|sh|inc|bak)$">
Order Allow,Deny
Deny from all
</FilesMatch>
Loaded with some common extensions, add more as you need.
If you really want a 404 (and not a 403), you can use mod_rewrite:
RewriteEngine on
RewriteRule \.ext$ - [R=404]