nginx相关配置

禁止访问目录下的文件

location ~ /Logs/ {
deny all;
return 403;
}

 

301跳转

server {
listen 80;
server_name www.baidu.com;
return 301 https://www.baidu.com$request_uri;
}

 

rewrite跳转

if ($host != 'www.baidu.com') {
rewrite ^/(.*)$ https://www.baidu.com/$1 permanent;
}

 

设置404页面

1、更改/usr/local/nginx/conf/nginx.conf在http定义区域加入: fastcgi_intercept_errors on;
2、更改网站站点nginx.conf 在网站配置中在server 区域加入: error_page 404   /404.html;

posted @ 2025-03-04 15:25  day959  阅读(6)  评论(0)    收藏  举报