Friday, March 12, 2021

Auto redirection of urls from http to https

Normally when a site is enabled with SSL, we need to auto redirect urls from http to https

Go to your web site's default document root folder.

Open your .httaccess file or create one ( I assume mod redirect is enabled in your web server)

Paste the below code.

RewriteEngine On 
RewriteCond %{HTTPS}  !=on 
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L] 

Test your domain without http, it will automatically redirect to https

No comments:

Post a Comment