Nginx设置域名301/302重定向
文章最后更新时间:2022年03月18日已超过103天没有更新。
server{ listen 80; server_name test.com test1.com test2.com; # apache不支持nginx可以 index index.html index.htm index.php; root /data/wwwroot/test.com; if ($host != 'test.com' ) { rewrite ^/(.*)$ http://test.com/$1 permanent; } }
server_name后面支持写多个域名,这里要和httpd的做一个对比
permanent为永久重定向,状态码为301,如果写redirect则为302
# /usr/local/nginx/sbin/nginx -t
# /usr/local/nginx/sbin/nginx -s reload
若文章图片、下载链接等信息出错,请联系反馈,博主将第一时间更新!如果喜欢本站,请打赏支持本站,谢谢!
文章版权声明:除非注明,否则均为阿豪运维笔记原创文章,转载或复制请以超链接形式并注明出处。