[英]How to restrict viewing of php.ini from all subdirectories?
我目前能夠更改.htaccess
文件,以防止通過網絡瀏覽器打開php.ini
和其他文件:
# Prevent .ini and other files from being open from web browser
<filesMatch "\.(htaccess|htpasswd|ini|log|sh)$">
Order Allow,Deny
Deny from all
</filesMatch>
但這似乎僅適用於放置.htaccess
文件的根目錄,因此,如果我導航到www.mysite.com/sub/php.ini
它仍然可以打開該文件。
知道如何對所有子目錄中的所有此類文件進行過濾嗎?
您可以將其添加到您的apache配置httpd.conf
,或添加到您的.htaccess
。
<Files "*.ini">
Require all denied
</Files>
或者這也可以工作:
<Files "*.ini">
Order Allow,Deny
Deny from all
</Files>
如果要保持當前的格式,可以執行以下操作:
<filesMatch ".*\.(htaccess|htpasswd|ini|log|sh)$">
Order Allow,Deny
Deny from all
</filesMatch>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.