How to Redirect HTTP to HTTPS on Apache — The Ultimate Guide

1 Star2 Stars3 Stars4 Stars5 Stars (7 votes, average: 5.00 out of 5)

Installing an SSL certificate on your Apache server is not the end of the process of securing your website. In fact it’s really only the beginning. Your website is still being served via HTTP — this means you’re going to need to re-write some URLs, create some redirects, and force HTTPS. This means you’ll need to redirect HTTP to HTTPS in Apache.

Fortunately, we’re here to help. In this guide we’ll discuss how to take care of all three in Apache to redirect permanently your site to the HTTPS protocol.

So, before we get started let’s assume you’ve already purchased and installed an SSL certificate on your Apache server. You’ll also need to have your SSL and rewrite modules active on Apache.

Save Up to 82% on RapidSSL DV SSL Certificates

Protect your website within few minutes with a Domain Validated (DV) SSL Certificate.

Get a RapidSSL DV SSL certificate, starting at $12.42/year

How to Redirect HTTP to HTTPS on an Apache Server

There are two primary ways that you could redirect HTTP to HTTPS in Apache:

  1. You could use mod_rewrite in Apache, or
  2. You can use the more secure virtual host redirect method.

We always think it’s best to go with the more secure methods. As such, let’s talk about redirecting your site to HTTPS using your virtual host:

  1. Open your virtual host.
  2. Paste this in:

    <VirtualHost *:80>
    Redirect permanent /

    <VirtualHost _default_:443>
    DocumentRoot / usr/local/apache2/htdocs
    SSLEngine On
    . . .

  1. Save.
  2. Go on living your life.