汽车vr网
您的当前位置:首页nginx如何设置禁止解析php文件

nginx如何设置禁止解析php文件

来源:汽车vr网


nginx设置禁止解析php文件的方法:可以根据目录来php解析。具体方法:首先打开配置文件;然后找到配置【location ~ .php$】,将其设置为【deny all】即可。

具体方法:

(推荐教程:nginx教程)

php解析

根据目录来php解析:

location ~ .*(diy|template|attachments|forumdata|attachment|image)/.*.php$
{
 deny all;
}

浏览器访问

使用 user_agent 控制客户端浏览器访问

location / {
 if ($http_user_agent ~ 'bingbot/2.0|MJ12bot/v1.4.2|Spider/3.0|YoudaoBot|Tomato|Gecko/20100315'){
 return 403;
 }
}
显示全文