为了加强网站安全性,我们除了限制目录权限外,还需要禁用某此目录禁止执行php。在IIS中可以直接将目录的脚本执行权限去掉,而针对非windows系统如何做呢?
接下来的文章将简单的介绍不同的webserver如何禁用php执行。。。。
[b]Apache:[/b]
<Directory /website/attachments>
php_flag engine off
</Directory>
[b]Nginx:[/b]
[b]禁用单个目录:[/b]
location /upload/ {
location ~ .*\.(php)?$
{
deny all;
}
}
[b]禁用多个目录:[/b]
location ~* ^/(upload|images)/.*\.(php|php5)$
{
deny all;
}
[b]Lighthttpd:[/b]
$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>