How to hide certain file type using apache .htaccess?

前端 未结 6 953
不知归路
不知归路 2020-12-15 07:59

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

6条回答
  •  爱一瞬间的悲伤
    2020-12-15 08:19

    @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 RewriteRule to establish case-insensitivity. But for some situations, it’s good to know that you can also roll with RedirectMatch by 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)
    

提交回复
热议问题