把 tmier.top和www.tmier.top合并到一个server上去,可以使用301永久重定向。

然后将 https://tmier.top 转到 https://www.tmier.top 去。不过要在配置文件的 `server` 

https://www.tmier.top 上配置default_server ssl;

301永久重定向可以把搜索引擎的权重全部集中到 https://www.tmier.top 上。


配置如下:


```php

server {

    listen       80;

    server_name tmier.top,www.tmier.top;

    return 301 https://tmier.top$request_uri;

}

server {

    listen 443;

    server_name tmier.top;

    return 301 https://www.tmier.top$request_uri;

}

server {

    listen 443 default_server ssl;

    server_name  www.tmier.top;

    ssl on;

    ssl_certificate 1_www.tmier.top_bundle.crt;

    ssl_certificate_key 2_www.tmier.top.key;

    ssl_session_timeout 5m;

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;

    ssl_prefer_server_ciphers on;

    root         /var/www/hexo;

    include /etc/nginx/default.d/*.conf;

    error_page 404 /404.html;

        location = /40x.html {

    }


    error_page 500 502 503 504 /50x.html;

        location = /50x.html {

    }

}

```


##### 参考文档


[腾讯云 Nginx Https 证书安装指引][1]

[nginx配置http强制跳转https][2]

转载自 [morethink][3] 博客



  [1]: https://cloud.tencent.com/document/product/400/4143

  [2]: https://docs.lvrui.io/2017/04/01/nginx%E9%85%8D%E7%BD%AEhttp%E5%BC%BA%E5%88%B6%E8%B7%B3%E8%BD%AChttps/%22

  [3]: https://www.cnblogs.com/morethink/p/8127344.html

点赞(277) 打赏

评论列表 共有 0 条评论

暂无评论
立即
投稿
发表
评论
返回
顶部