Http to https usando apache conf file

Per convertire in modo permanente tutto un sito da http a https si possono usare i file di configurazione del virtual host di apache e url_rewriter.
Si fa cosi, si aggiungono alla fine del file di configurazione di apache (es: sudo nano /etc/apache2/sites-available/example.com.conf) queste righe:
RewriteEngine on
RewriteCond %{SERVER_NAME} =example.com [OR]
RewriteCond %{SERVER_NAME} =www.example.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
Cambiando il dominio.
Poi si riavvia apache:
sudo service apache2 restart
Finito! Ora tutto viene mandato ad https.
Rating: 4 out of 5 by 1891 visitors

