Last Updated: February 25, 2016
· penguinpowernz

Forward all Apache HTTP traffic to HTTPS

This is a good way to force all traffic to your site to use HTTPS while letting people who forget the 's' in HTTPS still get to your site. Pretend it is at /etc/apache2/sites-available/ on a Debian system.

<VirtualHost *:80>
  <Location />
    Redirect permanent /

<VirtualHost *:443>
  DocumentRoot /home/example/

  SSLEngine On
  SSLCertificateFile /etc/apache2/ssl/
  SSLCertificateKeyFile /etc/apache2/ssl/
  SSLCertificateChainFile /etc/apache2/ssl/

As you can see the first VirtualHost definition captures all traffic coming in on port 80 for the domain and forwards it to port 443. Easy!

1 Response
Add your response

if you can't modify your virtual hosts file you can try modifying your .htaccess file to redirect the content

over 1 year ago ·