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 through out the
@Dário has the right idea for File Types, and it can also be used for specific files and directories as well. The only thing that is missing is to manage case sensitivity.
I came across this article that gives some detail about case-sensitive RedirectMatch, and also suggests being character case non-sensitive.
When it comes to redirecting most requests, its all lowercase anyway. Or you can use
RewriteRuleto establish case-insensitivity. But for some situations, it’s good to know that you can also roll withRedirectMatchby simply adding the(?i)to the rule.
RedirectMatch 403 /\$\&
RedirectMatch 403 (?i)/\.(bash|git|hg|log|svn|swp|tar)
RedirectMatch 403 (?i)/(1|contact|i|index1|iprober|phpinfo|phpspy|product|signup|t|test|timthumb|tz|visit|webshell|wp-signup).php
RedirectMatch 403 (?i)/(author-panel|class|database|manage|phpMyAdmin|register|submit-articles|system|usage|webmaster)/?$
RedirectMatch 403 (?i)/(=|_mm|cgi|cvs|dbscripts|jsp|rnd|userfiles)