社区微信群开通啦,扫一扫抢先加入社区官方微信群
社区微信群
一、自定义错误页面
1、在nginx配置文件nginx.conf的http中添加这样一句话,表明要使用自定义的错误提示页面:
fastcgi_intercept_errors on; #表明使用自定义错误提示
2、指定的server中配合,配置404.html或者500.html页面
fastcgi_intercept_errors on;
server {
listen 80;
error_page 404 /404.html; --页面放在html文件中或自定义位置
location = /404.html {
root html;
}
error_page 500 502 503 504 /50x.html; --页面放在html文件中或自定义位置
location = /50x.html {
root html;
}
}
二、自定义或者关闭favicon.ico,指的是下图的图标
# 把以下配置放到 server {} 块.
#关闭favicon.ico不存在时记录日志
location = /favicon.ico {
#root html; --或者自定义一个favicon.ico文件,将favicon.ico放到html目录。
return 404;
expires 30d;
log_not_found off; --关闭日志
access_log off; --不记录在access.log
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
# 不允许访问隐藏文件例如 .htaccess, .htpasswd, .DS_Store (Mac).
location ~ /. {
deny all;
access_log off;
log_not_found off;
}
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!