Redirect all Requests to HTTPS://WWW with Htaccess

Redirect all Requests to HTTPS://WWW with Htaccess

If you have SSL certificate for your domain name then you can enable https for your domain so that all your visitors can visit your website through secure protocol. Here were have shared a simple htaccess code to redirect all requests to https://www version of your website. Follow these steps to know how to redirect all requests http://example.com, https://example.com or http://www.example.com to https://www.example.com with a piece of htaccess code.

Redirect all Requests to https with www using htaccess code

1. Login to cPanel > File Manager > Public_html
2. Open the file .htaccess to edit and paste the following code into it:

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]

RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]

3. Now very carefully, change example.com to your own domain name and save the file.

After this code, all of your requests will be transferred to https://www version of the URL of your website.

Copyright © 2014-2018 Webxen.com. All rights reserved.