2016-02-21 22 views

risposta

7

Questo è un comportamento normale.
In realtà, è necessario verificare se www è nell'host o meno prima di eseguire un reindirizzamento.

Un modo semplice sarebbe quella di dividere il problema in due condizioni

RewriteEngine on 

# redirect http://www.example.com to https://www.example.com 
RewriteCond %{HTTPS} off 
RewriteCond %{HTTP_HOST} ^www\. [NC] 
RewriteRule^https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] 

# redirect http(s)://example.com to https://www.example.com 
RewriteCond %{HTTP_HOST} !^www\. [NC] 
RewriteRule^https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L] 
+1

funziona perfettamente grazie – Vazzilly

+0

Prego! –

+0

@JustinIurman HTTPS example.com su HTTPS www.example.com reindirizzamento manca? – Tom

0

È possibile utilizzare la seguente regola per reindirizzare a https://www

RewriteEngine on 
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ 
RewriteCond %{HTTPS} off 
RewriteRule (.*) https://www.%1%{REQUEST_URI} [L,R] 
+0

https: //www.%7Brequest_uri%7D/ è il risultato – Vazzilly

+0

@vazzilly c'è stato un lieve errore di battitura, (manca% entro il { REQUEST_URI}) L'ho risolto. – starkeen

Problemi correlati