https redirect with htaccess

After installing SSL on your site, we have a very simple code to redirect all incoming requests to https. When you paste this code into the .htaccess in your site’s main directory, all requests will now redirect to https.

<IfModule mod_rewrite.c>
 RewriteEngine On
 RewriteCond !{HTTPS} off
 RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
 RewriteCond %{HTTP_HOST} !^www\.
 RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>

You may also like...