2013-10-07 21 views
7

Questo è lo script che ho adesso, come faccio a far sì che il mio script imponga tutto il traffico a http, attualmente sta facendo l'esatto contrario, sta forzando tutto il traffico a https.Forzare http utilizzando .htaccess

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

Ho anche provato questo e non ha funzionato

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

ho ottenuto questo errore:

Too many redirects occurred trying to open www.blankpage.com .

risposta

25

si desidera verificare che HTTPS è su:

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

E se è attivo (%{HTTPS} on), reindirizzare a http://. Non esiste una variabile mod_rewrite denominata %{HTTP}, solo %{HTTPS} che può essere "on" o "off".

Il motivo per cui si stavano diventando il troppi reindirizzamenti errore è perché:

RewriteCond %{HTTP} !=on 

è sempre vero, non importa se la richiesta è http o https, dal momento che la variabile non esiste, lo farà mai uguale a "on". Pertanto, anche se la richiesta è http, continuerai a essere reindirizzato allo stesso URL (http).

+0

Grazie per la spiegazione !! Ciò ha senso! –

Problemi correlati