完美解決瀏覽器輸入http被自動跳轉至https問題

在將服務嘗試著從http協議往https協議遷移成功之後,又出於測試調試的目的將服務轉回到http協議,卻發現在瀏覽器輸入http會被自動跳轉到https。

HTTP Strict Transport Security (HSTS) is an opt-in security enhancement that is specified by a web application through the use of a special response header. Once a supported browser receives this header that browser will prevent any communications from being sent over HTTP to the specified domain and will instead send all communications over HTTPS. It also prevents HTTPS click through prompts on browsers.

查閱相關資料,發現這是瀏覽器的HSTS(HTTP Strict Transport Security)功能引起的。在安裝配置SSL證書時,可以使用一種能使數據傳輸更加安全的Web安全協議,即在服務器端上開啟HSTS ,它會告訴瀏覽器隻能通過HTTPS訪問,而絕對禁止HTTP方式。

因此,隻要關閉瀏覽器的HSTS功能就可以解決這個問題,但是隻能通過特定的方式,而不是清除瀏覽器緩存那麼簡單。

Chrome瀏覽器

1.地址欄中輸入chrome://net-internals/#hsts。

2.在Delete domain中輸入項目的域名,並Delete(刪除)

3.可以在Query domain測試是否刪除成功。

Opera瀏覽器

和Chrome方法一樣。

Safari瀏覽器

1.完全關閉Safari瀏覽器。

2.刪除~/Library/Cookies/HSTS.plist這個文件。

3.重新打開Safari即可(極少數情況下,可能需要重啟系統)。

Firefox瀏覽器

1.關閉所有已打開的頁面。

2.清空歷史記錄和緩存。

3.地址欄輸入about:permissions。

4.搜索項目域名,並點擊Forget About This Site。

ps:下面看下解決谷歌瀏覽器http鏈接自動跳轉到https的問題

有些網址http協議和https協議是兩個服務,有時候需要訪問http地址,但chrome會默認轉成https請求地址,

輸入 http://baidu.com 會自動跳轉到 https://baidu.com

這時候清理瀏覽器緩存之類的都是沒有用的,需要進行如下操作,

在chrome瀏覽器地址輸入:chrome://net-internals/#hsts

在這裡插入圖片描述

在最下面的Delete domain security policies
裡輸入想要刪除的網址,註意是去掉http://前綴的網址,如:h5.baidu.com

到此這篇關於瀏覽器輸入http被自動跳轉至https問題的文章就介紹到這瞭,更多相關http自動跳轉至https內容請搜索WalkonNet以前的文章或繼續瀏覽下面的相關文章希望大傢以後多多支持WalkonNet!

推薦閱讀: