Ridirigere in modo corretto il traffico da http a HTTPS

Di seguito i dettagli sulla procedura per redirigere il traffico da http a HTTPS.

Modifica del file .htaccess

Di seguito le operazioni da seguire per ridirigere il traffico da http a HTTPS:

  1. RIDIRIGERE TUTTO IL TRAFFICO HTTP VERSO HTTPS: inserire nella radice del dominio un file .htaccess contenente le seguenti righe (o, in caso di file esistente, aggiungere a quanto già presente):
    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTPS} off
    RewriteCond %{HTTP:X-Forwarded-Proto} !https
    RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

     

  2. RIDIRIGERE TUTTO IL TRAFFICO CON L’ECCEZIONE DI UNA CARTELLA: modificare il codice nel seguente modo:
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_URI} !^/cartella_da_escludere
    RewriteCond %{HTTPS} off
    RewriteCond %{HTTP:X-Forwarded-Proto} !https
    RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
  3. RIDIRIGERE IL TRAFFICO DI UNA SINGOLA CARTELLA DA HTTP AD HTTPS: il file .htaccess deve essere inserito nella cartella che si desidera funzioni solo via https e conterrà le seguenti righe:
    RewriteEngine On
    RewriteBase /cartella_https
    RewriteCond %{HTTPS} off
    RewriteCond %{HTTP:X-Forwarded-Proto} !https
    RewriteRule^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Le migliori offerte di Informatica, con spedizione GRATUITA.
tablet ebay x

Informazioni su Luciano Del Fico 21053 Articoli
Appassionato di Informatica, Blogger, Webmaster, Scrittore, Contabile, seguimi su questo Blog troverai le migliori offerte di tecnologia e tutto quello che avresti voluto sapere su WordPress, CMS, PHP, Webdesign e Programmazione.

Commenta per primo

Rispondi