本文章来给大家介绍在apache环境中如何禁止指定目录执行php,htm,asp文件的方法,下面我介绍利用apache,hatccess的方法,同时还有nginx中的配置方法。
htaccess禁止php,htm
php_flag engine off
- <Files ~ ".php">
- order allow,deny
- deny from all
- </Files>
- <Files ~ ".htm">
- order allow,deny
- deny from all
- </Files>
- <Files ~ ".html">
- order allow,deny
- deny from all
- </Files>
- <FilesMatch (.*).htm$>
- order allow,deny
- deny from all
- </FilesMatch>
- <FilesMatch (.*).html$>
- order allow,deny
- deny from all
- </FilesMatch>
在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>
nginx
- location /data/ {
- location ~ .*.(php)?$ {
- deny all;
- }
- }
|