为了加强网站安全性,我们除了限制目录权限外,还需要禁用某此目录禁止执行php。在IIS中可以直接将目录的脚本执行权限去掉,而针对非windows系统如何做呢?
接下来的文章将简单的介绍不同的webserver如何禁用php执行。。。。
Apache:
<Directory /website/attachments> php_flag engine off </Directory>
Nginx:
禁用单个目录:
location /upload/ { location ~ .*\.(php)?$ { deny all; } }
禁用多个目录:
location ~* ^/(upload|images)/.*\.(php|php5)$ { deny all; }
Lighthttpd:
$HTTP["url"] =~ “^/(forumdata|templates|customavatars?)/” { fastcgi.server = () }Apache
<Location “/forumdata”> php_admin_flag engine off Options -ExecCGI AddType text/plain .html .htm .shtml .php </Location>