Pages

Thursday, September 25, 2014

Debian automatic apache redirect to https

This post just show how to enable redirecting all traffic from http://site to https://site. It does NOT cover the part of configuring Apache for SSL

Make mod rewrite enabled in apache:
# ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/
Edit /etc/apache2/sites-enabled/000-default
Add the following lines in <VirtualHost *:80> section:
RewriteEngine on
ReWriteCond %{SERVER_PORT} !^443$
RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [NC,R,L]

Save the file and restart the apache web server.

No comments: