If your website uses Apache and SSL, there’s not much reason to keep using HTTP with your website. Having both HTTP and HTTPS just creates duplicate content, as now any given page will be accessible through two technically different URLs.
In this guide, we’ll assume you’re already using Apache on a Linux system and want to redirect all HTTP traffic to HTTPS. This will make sure that all your visitors are only connecting through HTTPS by forcing their browser over to the secure protocol if they happen to open an HTTP link. If a user decides to preface a link with http://
, your site will be smart enough to still send them to the correct page, rather than showing duplicate content or displaying a 404 error.
There are two ways to set up this redirection in Apache. The better method is to configure Virtual Host, but users with hosted websites may not have access to this configuration. The second method is by making some changes to the .htaccess
file. We’ll cover the step by step instructions for both methods below. Let’s get started.
In this tutorial you will learn:
- How to redirect HTTP to HTTPS with Virtual Host
- How to redirect HTTP to HTTPS with
.htaccess
file