Apache .htaccess拒绝访问重要文件

时间:2017-01-08 03:50:49

标签: php apache .htaccess

我和正则表达式有点混淆使用<Files><FilesMatch>

之间的区别

如果你看一下下面的规则,我已经对它们进行了一些修改,我不确定它是对的,哪些是错的。

# Deny access to all important files (Misc)
<FilesMatch "^\.*(error_log|bak|config|ini|log|sh|sql|swp|wp-config\.php|php.ini|\.[hH][tT][aApP].*)$">
order deny,allow
deny from all
</FilesMatch>

# Deny access to all .htaccess files (Main)
<FilesMatch "\.htaccess">
order allow,deny
deny from all
</FilesMatch>

# Deny access to every type of .htaccess file (Extra check)
<FilesMatch "^.*\.([Hh][Tt][AaPp])$">
order allow,deny
deny from all
satisfy all
</FilesMatch>

# Deny access to every file EXCEPT the following (High Security)
Order deny,allow
Deny from all
<FilesMatch "^\.(xml|css|js|jpe?g|png|gif|xlsx|xls|xlsm|doc|docx|pdf)$">
Allow from all
</FilesMatch>

如果你看第一条规则,我不确定什么是正确的

"^\.*(error_log|bak|config|ini|log|sh|sql|swp|wp-config\.php|php.ini|\.[hH][tT][aApP].*)$"

我应该只看扩展名吗?

php.ini和wp-config以及.htaccess实际上是否正常工作?因为这肯定是在寻找:.wp-config.php例如显然是错误的。

0 个答案:

没有答案