HTTPS Redirection

In Apache

In your Apache server and go to the conf folder and take a backup of httpd.conf file. Open httpd.conf using your favourite editor. Ensure mod_rewrite.so module is loaded.

LoadModule rewrite_module modules/mod_rewrite.so

If you see above line is commented then uncomment it. Add the following at the end of the file.

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

Restart Apache web server to test it.

Now your configured website should be able to redirect and accessible on https.

In .htaccess

First, you need to ensure SSL is enabled for your site. Look for .htaccess file use to be on the root and add the following at the end of the file.

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

It is not necessary to repeat “RewriteEngine On” if it is already in the file.