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;
[....]
}
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。
最后
以上就是要减肥皮卡丘最近收集整理的关于详解nginx服务器http重定向到https的正确写法的全部内容,更多相关详解nginx服务器http重定向到https内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复