skip to Main Content

According to the tool below, I’m not redirecting our site to HTTPS properly.

https://www.linksspy.com/seo-tools/free-seo-ssl-scan/barefootmosquito-com

Does anyone know the proper way to 301 redirect all versions of a homepage to https://www.example.com? These are the other versions of a homepage I’m referring to:

http://example.com
http://www.example.com
https://example.com?

I found this question asked a few years ago, but there was a lot of back and forth about what the best way to do this was, and there didn’t seem to be a definite answer among the group.

Any help would be much appreciated. Thank you in advance!

2

Answers


  1. To redirect your http non-secure traffic over the https secure page, you need to add below code into your .htaccess file. Once you update your .htaccess file then http, www and non-www all requests use the 301 permanent redirection tool and redirect on https secure protocol.

    RewriteEngine On
    RewriteCond %{SERVER_PORT} 80
    RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [R,L]
    
    Login or Signup to reply.
  2. You should use below code for 301 redirection, it will definitely work for you.

    RewriteCond %{HTTPS} !on [OR]
    RewriteCond %{HTTP_HOST} !^www.
    RewriteRule (.*) https://www.domainname.com%{REQUEST_URI} [L,R=301]
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search