Home » Topic » .htaccess code to redirect non www to www http:// and https://

.htaccess code to redirect non www to www http:// and https://

Anuraag Singh ~ Modified: July 2nd, 2015 ~ ~ 1 Minute Reading

Home Forums .htaccess code to redirect non www to www http:// and https://

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #301 Score: 0

    Most of the users are looking for .htaccess code to redirect http:// to https:// and even after they need to know what exactly to add redirect non www to www for both http:// and https://

    Here is the exact .htaccess code for same, this code needs to be placed in .htaccess

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$
    RewriteCond %{HTTPS}s ^on(s)|
    RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

    So, suppose if you have a domain say domain.com it will redirect to http://www.domain.com
    And if you try to visit https://domain.com it will redirect you https://www.domain.com

    Let me know, if still anybody need any assistance.

Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.