2017-10-28 33 views
0

我的WordPress網站是在WordPress管理https://www.example.comSettings/general的WordPress從http反彈至HTTPS和回HTTP,然後終於到https

我使用Simple SSL插件。這是我的.htaccess

<IfModule mod_rewrite.c> 
RewriteEngine on 
#RewriteCond %{HTTP_HOST} =example.com 
#RewriteRule (.*) https://www.example.com/$1 [R=301,L] 
RewriteCond %{HTTP_HOST} ^example.com[nc] 
RewriteRule ^(.*)$ http://www.example.com/$1 [r=301,nc] 
RewriteCond %{SERVER_PORT} 80 
RewriteCond %{REQUEST_URI} wp-admin 
RewriteRule ^(.*)$ https://www.example.com/wp-admin/ [R,L] 
</IfModule> 



# BEGIN rlrssslReallySimpleSSL rsssl_version[2.5.22] 
<IfModule mod_rewrite.c> 
RewriteEngine on 
RewriteCond %{HTTP:X-Forwarded-Proto} !https 
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] 
</IfModule> 
# END rlrssslReallySimpleSSL 

出於某種原因,當去到example.com它從基於HTTP> https->基於HTTP> HTTPS

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

回答

0

3名重定向如果X-轉發 - 協議是決定是否請求的方式通過HTTPS來不來,我相信你可以用這個代替一切:

<IfModule mod_rewrite.c> 
RewriteEngine on 
RewriteCond %{HTTP:X-Forwarded-Proto} !https 
RewriteRule ^(.*)$ https://www.example.org%{REQUEST_URI} [R=301,L] 
</IfModule> 

把它放在.htaccess中的WP塊之前。如果SSL直接在您的Apache中處理,請用RewriteCond %{SERVER_PORT} 80

+0

替換RewriteCond行,如果我這樣做,它永遠不會導航到「https:// www.example.com」。它停留在'https:\\ example.com'。它實際上這樣做,即使我從htaccess中刪除所有內容 – codeNinja

+0

你使用哪一個,有'X-Forwarded-Proto'或'SERVER_PORT'?你也試過另一個嗎? – janh

+0

我試過'x-forwarded-proto'。我也嘗試了其他。都導致反彈 – codeNinja