亲宝软件园·资讯

展开

nginxhttps重定向http 详解nginx服务器http重定向到https的正确写法

Bruce.Tang 人气:0
想了解详解nginx服务器http重定向到https的正确写法的相关内容吗,Bruce.Tang在本文为您仔细讲解nginxhttps重定向http的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:nginx,重定向https,nginx,重定向到https,nginxhttps重定向http,下面大家一起来学习吧。

http重定向到https使用了nginx的重定向命令。那么应该如何写重定向?之前老版本的nginx可能使用了以下类似的格式。

rewrite ^/(.*)$ http://domain.com/$1 permanent;

或者

rewrite ^ http://domain.com$request_uri? permanent;

现在nginx新版本已经换了种写法,上面这些已经不再推荐。

下面是nginx http页面重定向到https页面最新支持的写法:

server {
  listen   80;
  server_name  my.domain.com;
  return   301 https://$server_name$request_uri;
}

server {
  listen   443 ssl;
  server_name  my.domain.com;

  [....]
}

加载全部内容

相关教程
猜你喜欢
用户评论