2016-09-14 56 views
1

我有域hubket.com,我通過godaddy啓用了https。現在它已正確啓用https,如果你打開它。如何在WordPress中使用.htaccess啓用HTTPS?

現在,我想轉換成WWW或者WWW沒有爲所有用戶像這樣http://www.hubket.com

我試圖將啓用在這樣的教程一些測試代碼!

測試1

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase/
RewriteCond %{ENV:HTTPS} !=on 
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L] 
# BEGIN WordPress 
RewriteRule ^index\.php$ - [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /index.php [L] 
</IfModule> 

測試2

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

請幫我開HTTPS爲所有用戶。

感謝

回答

1

試試這個,沒有需要進行更改(如url):

RewriteEngine On 
RewriteCond %{HTTPS} !=on 
RewriteRule^https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 

除了這個htaccess代碼片段,您絕對必須使用https://搜索並替換數據庫中的所有http://鏈接。爲此,我可以向您推薦this script

+0

我已編輯您的建議代碼。但我害怕做你建議我的DB腳本。因爲可能會影響DB。任何其他或安全的解決方案? –

+0

當然,它會影響你的數據庫。在使用此腳本之前執行備份,然後用您的建議腳本更新您的博客URL並使用它的https版本 –

+0

更新替換。現在用https強行登錄,但普通網站並不強制用https打開,仍然用非https開啓 –

0

你可以嘗試以下方法:

RewriteEngine On 
RewriteCond %{HTTP_HOST} ^hubket\.com [NC] 
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.hubket.com/$1 [R,L] 
+0

我已經添加了,但仍然打開非https,只打開www.hubket.com,你能提出任何其他解決方案 –

+0

你在你的主機上安裝了SSL證書嗎? – Prasad

+0

是的,你可以檢查https://www.hubket.com它正在打開罰款 –

0

試試這個

RewriteEngine On 
RewriteCond %{HTTP_HOST} ^example\.com [NC] 
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L] 

確保使用域名來代替example.com

+0

我已經發布第一個與虛擬網站名稱 – Prasad

相關問題