nginx 301 重定向 域名到 www

技术分享 2020-07-15 21:59:39
刚开始用dnspod 的显性转发可是无奈百度的收录都是重影的,查询dnspod的301重发服务器总是美国的地址,莫名其妙


本来图dnspod的方便 ,还是自己的服务器靠得住,不在乎这点服务器压力,改用自己的nginx转发 server_name www.pbottle.com pbottle.com;
if ($host = 'pbottle.com' ) {
rewrite ^/(.*)$ https://www.pbottle.com/$1 permanent;
}


结果:

HTTP/1.1 301 Moved Permanently
Server: nginx/1.2.9
Date: Tue, 14 Jan 2014 17:19:02 GMT
Content-Type: text/html
Content-Length: 184
Connection: keep-alive
Location: https://www.pbottle.com/