CodeSteps

Python, C, C++, C#, PowerShell, Android, Visual C++, Java ...

Apache – How to redirect HTTP to HTTPS?

Once you have installed SSL Certificate on your website, you need to redirect HTTP version of your website to point to the HTTPS version. This way, you are enabling the complete secured access to your website. No body, will be able to access your non-secured site, which is through HTTP.

Through this article, we are going to discuss the steps to redirect your HTTP site to HTTPS by modifying .htaccess file. Before you start applying below steps, ensure to install SSL Certificate for your site.

I have verified below steps with one of my WordPress site, and it worked very well.

Step 1. Log in into the site, where your website files are installed.

Step 2. Look for .htaccess file. It may be a hidden file, you can select the option to show the hidden files.

Step 3. Open the .htaccess file for editing and type below entries in the file. I have added these entry before “# BEGIN WordPress” section for my WordPress site.

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]

Step 4. Save the file and try to access your website using HTTP path and observe that, it automatically redirects to HTTPS site; a secured site.

This way, all of the traffic to your HTTP site; will route to your HTTPS site.

.Paul.

Apache – How to redirect HTTP to HTTPS?

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top