dopost 发表于 2018-11-19 07:24:56

linux下nginx apache lighttpd 禁止某些目录执行php

  为了加强网站安全性,我们除了限制目录权限外,还需要禁用某此目录禁止执行php。在IIS中可以直接将目录的脚本执行权限去掉,而针对非windows系统如何做呢?
  接下来的文章将简单的介绍不同的webserver如何禁用php执行。。。。
  php命令执行
  Apache
  1
  
  2
  php_flag engine off
  3
  
  Nginx
  禁用单个目录:
  1
  location /upload/ {
  2
  location ~ .*\.(php)?$
  3
  {
  4
  deny all;
  5
  }
  6
  }
  禁用多个目录:
  1
  location ~* ^/(upload|images)/.*\.(php|php5)$
  2
  {
  3
  deny all;
  4
  }
  lighthttpd
  01
  $HTTP["url"] =~ “^/(forumdata|templates|customavatars?)/” {
  02
  fastcgi.server = ()
  03
  }
  04
  05
  Apache:
  06
  07
  
  08
  php_admin_flag engine off
  09
  Options -ExecCGI
  10
  AddType text/plain .html .htm .shtml .php
  11
  
  转自:https://baoz.net/nginx-apache-lighttpd-disable-php/

页: [1]
查看完整版本: linux下nginx apache lighttpd 禁止某些目录执行php