如何实现访问http自动跳转https

一、http自动跳转https

首先服务器肯定得有ssl证书,新建http和https两个网站,指向同一个物理路径

可以在phpstudy中测试,生成开发者证书及测试开启http自动跳转https

在配置文件中体现为
apache:
RedirectMatch permanent ^/(.*) https://gpysir.design/$1
nginx:
rewrite ^(.*)$ https://$gpysir.design/$1 permanent

 

 二、除此可以实现301重新向页面

使用场景:

网站改进,一些url失效,可以全部重新向到新页面

原文地址:https://www.cnblogs.com/gpysir/p/14521431.html