通过修改配置文件,实现404错误页面重定向到首页或者指定网址:

error_page 404 = @redirect_to_home;
location @redirect_to_home {
add_header Cache-Control "no-cache, no-store, must-revalidate";
add_header Pragma "no-cache";
add_header Expires "0";
return 301 https://改为你的网址;
}
通过以上配置,当搜索引擎爬虫访问网站上的404页面时,Nginx 服务器将自动将其重定向到指定网址
网友评论