Redirect http to https and www to https with htaccess

Here is how to simply redirect your domain to always use https:// with no www.

This htaccess file will redirect:

  • http:// to https://
  • http://www. to https://
  • https://www. to https://

And here it is:

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

Simply create this as your .htaccess file and upload.

Or just download this htaccess file in zip format (also in this zip is file.htaccess incase the .htaccess is invisible, just upload file.htaccess and rename to .htaccess).

Leave a Comment

Your email address will not be published. Required fields are marked *