由於搜尋引擎對於 https 有較大的加分, 於是我申請了 SSL
可是搜尋引擎上面收錄的網址仍然是 http
我自己寫了一小段程式, 放在原本的首頁前,
就可以將連進來的 http 自動改成 https
( 前提 : 你的網址必須有ssl )
<script type='text/javascript'>
var url = document.location.href;
var len = url.length;
var http = url.substring(0,5);
if (http != "https") {
var url = "https://" + url.substring(7,len);
window.location.replace(url);
}
</script>
範例請看
http://fatew.com , 會自動變成
https://fatew.com
網頁按右鍵 > 檢視原始檔 !!
希望這樣能提高網站在搜尋引擎的排名.