拼多多網(wǎng)頁版進(jìn)入 如何實(shí)現(xiàn)用戶用訪問http時(shí)自動(dòng)跳轉(zhuǎn)到https的訪問地址?
如何實(shí)現(xiàn)用戶用訪問http時(shí)自動(dòng)跳轉(zhuǎn)到https的訪問地址?我們都知道http是明文傳輸不安全,現(xiàn)在好多都必須https傳輸,我們現(xiàn)在需要做的,還是訪問80端口,80自動(dòng)跳轉(zhuǎn)到443.Tomcat配置
如何實(shí)現(xiàn)用戶用訪問http時(shí)自動(dòng)跳轉(zhuǎn)到https的訪問地址?
我們都知道http是明文傳輸不安全,現(xiàn)在好多都必須https傳輸,我們現(xiàn)在需要做的,還是訪問80端口,80自動(dòng)跳轉(zhuǎn)到443.
Tomcat配置如下:
1.server.xml設(shè)置:
<Connector port="80" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="443" />
2.web.xml設(shè)置
<!--添加到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 自動(dòng)跳轉(zhuǎn) https://localhost.
讓技術(shù)之花,在頭條盛開……
也可以直接查看到我的頭條文章:Tomcat設(shè)置http自動(dòng)跳轉(zhuǎn)https