2015-09-13 21 views
0

所有請求,但沒有一個答案爲我工作。重定向到我搜索了我的問題對SO解決非www HTTPS

這就是我想要實現:

Redirect all 

http://example.com -> https://example.com 
http://www.example.com -> https://example.com 
https://www.example.com -> https://example.com 

基本上我想,無論域的形式訪問被重定向到非WWW HTTPShttps://example.com

+0

此問題之前已被詢問。 這裏是解決方案:http://stackoverflow.com/questions/12050590/redirect-non-www-to-www-in-htaccess – Themud

+0

這不是我期待的。 – m3tsys

回答

1

您可以使用在您的.htaccess

RewriteCond %{HTTP_HOST} ^www\.(.+) [NC] 
RewriteRule^https://%1%{REQUEST_URI} [NE,L,R=301] 
RewriteCond %{HTTPS} off 
RewriteRule^https://%{HTTP_HOST}%{REQUEST_URI} [NE,L,R=301] 
+0

同樣的老問題:'ERR_TOO_MANY_REDIRECTS' – m3tsys

+0

不是我的代碼,它在你的配置或htaccess的與其他規則 – Croises

+0

它是在htaccess的唯一代碼。 這裏是頭部看起來像現在: 'HTTP/1.1 400錯誤的請求=> 服務器=> CloudFlare的-nginx的 日期=>孫,2015年9月13日十八點29分47秒GMT 的Content-Type => text/html的 的Content-Length => 177 連接=> close' – m3tsys