2015-01-26 59 views
0

如何強制SSL與htaccess的 有了這個代碼,我收到了重定向錯誤鉻:如何強制ssl與htaccess?

RewriteEngine On 
RewriteCond %{HTTPS} !^on$ [NC] 
RewriteRule . https://%{HTTP_HOST}/%{REQUEST_URI} [L] HTTPS_HOST ??? 

感謝

+0

不這樣做。爲你的非ssl版本設置一個單獨的虛擬主機,並在其中放置一個無條件的'RedirectPermanent'指令。 – 2015-01-26 22:14:53

+0

我只有Web空間,我無法訪問服務器上的文件。有沒有其他的方式來強制ssl? – user3135461 2015-01-26 22:16:01

+0

[強制SSL/HTTPS使用。htaccess以及mod \ _rewrite](http://stackoverflow.com/questions/4398951/force-ssl-https-using-htaccess-and-mod-rewrite) – lpd 2016-05-16 18:50:58

回答

0

您可以使用:

RewriteEngine On 
RewriteCond %{HTTPS} off 
RewriteRule^https://%{HTTP_HOST}%{REQUEST_URI} [NE,L,R=301] 
+0

這麼想的的可能的複製工作,得到一個重定向錯誤。 (錯誤:頁面顯示重定向) – user3135461 2015-01-26 22:24:18

+0

刪除緩存和/或其他瀏覽器 – Croises 2015-01-26 22:25:18

+0

這麼想的工作嘗試用不與Firefox,同樣的錯誤,還與PHP版本,我得到一個重定向錯誤清除緩存也 – user3135461 2015-01-26 22:29:57

0

我建議你使用這個代碼其工作正常

#Force SSL 

RewriteEngine On 
RewriteCond %{HTTPS} off 
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}