nginx禁止指定目录运行php,只需要在server配置段中增加个location规则就可以了。
推荐:《PHP教程》
1、禁止某一个目录执行php
location ~* ^/download/.*\.(php|php5)${deny all;}
2、禁止多个目录执行php
location ~* ^/(download|down)/.*\.(php|php5)${deny all;}
注意:要写在php配置前,下面是一个示例
location ~* ^/(download|down)/.*\.(php|php5)${deny all;}location ~ [^/]\.php(/|$){try_files $uri =404;fastcgi_pass unix:/tmp/ph<strong>*本文来源gaodai#ma#com搞@代~码^网+</strong><strong>搞代gaodaima码</strong>p-cgi.sock;fastcgi_index index.php;include fastcgi.conf;}
以上就是nginx禁止指定目录运行php的详细内容,更多请关注搞代码gaodaima其它相关文章!