Redirect all Requests to HTTPS Non-WWW with htaccess

Redirect all Requests to HTTPS Non-WWW with htaccess

We can redirect all requests to https non-www version of a domain names using a simple code in our htaccess files. For this you need to paste a piece of code in the htaccess file which you can find in the public_html directory of file manager. Using this code all requests for your domain like http://example.com, https://www.example.com and http://www.example.com will be automatically transferred to non-www https version of your domain like https://example.com which is good for SEO purposes.

Redirect all Requests to HTTPS Non-WWW with htaccess

1. Login to cPanel > File Manager > Public_html directory
2. Open .htaccess file to edit and paste this code in that file:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.*)$ [NC]
RewriteRule (.*) https://%1%{REQUEST_URI} [L,R=301]

3. Save the file. Now all requests for your domain will be automatically redirected to https:// non-www version of your domain.

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