1. 301重定向设置
说明:访问网站 主域名 和 二级域名 重定向到同一个页面。
例子:访问 test.com 或者 www.test.com 重定向到 www.test.com
找到 www.test.com虚拟主机的 conf 文件。在 server 段加入红框内容:
if ($host != www.test.com) {
rewrite ^/(.*)$ $scheme://www.test.com/$1 permanent;
}
重启 nginx 服务。
2. 404页面设置
找到 www.test.com虚拟主机的 conf 文件。在 http 段加入红框内容:
fastcgi_intercept_errors on;
然后在 server 段指定404页面
error_page 404 = /404.html;
重启 nginx 服务。