工作中碰到一些目录需要写入数据,为了安全起见需要屏蔽特定路径下的php,python解析。


nginx相关配置:

location ~/(data|sites/upload)/.*\.(php|php5|py|pyc|sh)?$ {

deny all;

}



apache相关配置:

<Directory /usr/local/apache/htdocs/bbs/data>

php_flag engine off

</Directory>

<Directory ~ "^/home/centos/web/data">

 <Files ~ ".php">

 Order allow,deny

 Deny from all

 </Files>

</Directory>



相关阅读:

http://stackoverflow.com/questions/1271899/disable-php-in-directory-including-all-sub-directories-with-htaccess