修改port=“80”的Connector
<Connector port="80" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="443" />
把redirectPort指向443端口,也就是上面添加的Connector就行了。
也可以直接把之前的port=“80”的Connector的相關(guān)參數(shù)配置得和port=“443”的Connector一樣,但是一般不這樣做,因?yàn)檫@樣不方便以后跟換Connector配置。文章來源:http://www.zghlxwxcb.cn/news/detail-554197.html
修改web.xml
如上步驟完成后,只是可以用https://開頭訪問對應(yīng)網(wǎng)站,但是只輸入www.xxx.com時(shí),訪問的還是http://www.xxx.com,不會(huì)自動(dòng)變成https://www.xxx.com,要讓http自動(dòng)變成https,還需要修改同目錄下的web.xml。
操作很簡單,只需要在后面(文件末尾)添加如下代碼即可。文章來源地址http://www.zghlxwxcb.cn/news/detail-554197.html
<login-config>
<!-- Authorization setting for SSL -->
<auth-method>CLIENT-CERT</auth-method>
<realm-name>Client Cert Users-only Area</realm-name>
</login-config>
<security-constraint>
<!-- Authorization setting for SSL -->
<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>
到了這里,關(guān)于http請求自動(dòng)跳轉(zhuǎn)為https的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!