拼多多网页版进入 如何实现用户用访问http时自动跳转到https的访问地址?
如何实现用户用访问http时自动跳转到https的访问地址?我们都知道http是明文传输不安全,现在好多都必须https传输,我们现在需要做的,还是访问80端口,80自动跳转到443.Tomcat配置
如何实现用户用访问http时自动跳转到https的访问地址?
我们都知道http是明文传输不安全,现在好多都必须https传输,我们现在需要做的,还是访问80端口,80自动跳转到443.
Tomcat配置如下:
1.server.xml设置:
<Connector port="80" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="443" />
2.web.xml设置
<!--添加到web.xml 最后面-->
<security-constraint>
<web-resource-collection>
<web-resource-name>SSL</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
3.重启Tomcat测试
http://localhost 自动跳转 https://localhost.
让技术之花,在头条盛开……
也可以直接查看到我的头条文章:Tomcat设置http自动跳转https