本文章來給大家介紹在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;
- }
- }
新聞熱點
疑難解答