How to Redirect NON WWW to WWW https using htaccess

Discussion in 'Web Hosting Tutorials' started by Gupta, Nov 4, 2017.

  1. Gupta

    Gupta Administrator Staff Member Admin Premium Member

    Joined:
    Jul 13, 2017
    Messages:
    129
    Likes Received:
    28
    If you are looking to redirect non www http to https www version

    For example if you are looking to redirect http://domain.com to https://www.domain.com

    then add the below code to .htaccess

    Code:
    RewriteEngine On
    
    RewriteCond %{HTTP_HOST} !^www\. [NC]
    RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]
    
    RewriteCond %{HTTPS} off
    RewriteRule ^(.*)$ https://www.domain.com/$1 [L,R=301] 
    Make sure to replace domain.com with your actual website name
     



Loading...

Share This Page