HOWTO+-+Apache+Redirect+HTTP+to+HTTPS

Assuming you have apache2 installed run the following commands:

code a2enmod ssl a2enmod rewrite a2ensite default-ssl code

edit the file **///etc/apache2/sites-available/default//** and add the following lines exactly under the **////** line:

>  >> RewriteEngine On >> RewriteCond %{HTTPS} off >> RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

code /etc/init.d/apache2 restart code