網域名稱俱樂部

網域名稱俱樂部 (https://www.domainclub.org/index.php)
-   網址註冊、移轉及設定 (https://www.domainclub.org/forumdisplay.php?f=24)
-   -   將 http 自動轉成 https (https://www.domainclub.org/showthread.php?t=38022)

spline88 2015-05-15 01:17 PM

將 http 自動轉成 https
 
由於搜尋引擎對於 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

網頁按右鍵 > 檢視原始檔 !!

希望這樣能提高網站在搜尋引擎的排名.

spline88 2015-05-25 04:39 PM

在 Google 搜尋 "算命" , 排第三名, 而且已經以 https 收錄.

但是 Yahoo 搜尋 "算命" , 排第七名, 但仍未以 https 收錄.

cindy0328 2016-09-23 01:29 PM

我點你算命網不會自動跳轉阿

peer 2016-09-23 02:13 PM

有沒有推薦的SSL服務呢?有的要一萬多!不便宜呀。

cathaylist 2016-09-23 04:54 PM

一般不是都用 .htaccess 做這件事嗎? 這樣crawler也才知道不是?

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

chennien 2016-09-23 06:50 PM

如果希望網站未來通通用 https,還可以加上這段 HSTS header,
或甚至寫入到 HSTS Preload List:hstspreload.appspot.com/?domain=nien.com,強化網站安全性。

<ifModule mod_headers.c>
Header set Strict-Transport-Security "max-age=15552000; includeSubDomains; preload"
</ifModule>


Cloudflare 很好用,除了代管 DNS 外,
我也都用它的 Universal SSL,大推 ~yes 。

dclee9 2016-09-24 04:06 PM

自己會安裝SSL
就去 SSLs.com 最便宜。自助式的。

我們公司也有賣SSL
費用包含遠端安裝費用。


所有時間均為 +8。現在的時間是 05:16 AM

Powered by vBulletin® 版本 3.8.4
版權所有 ©2000 - 2024,Jelsoft Enterprises Ltd.