.htaccess 301 re-direct and canonicalization

2 replies
  • SEO
  • |
Hi,

I was wondering if anyone could shed some light on an issue i have been trying to get my head around for a while now which is multiple versions of the same website and 301 re-directs. I understand the basic principle but struggle with the details.

So from what i understand, for my site there will be

mysite.co.uk
www.mysite.co.uk
http://mysite.co.uk

I also have an SSL certificate installed on the domain so also

https://www.mysite.co.uk
https://mysite.co.uk

Is there a way to see which versions have been indexed or is it a case of they all will be?

I would prefer to use the domain www.mysite.co.uk so if i redirect all of the others to the www.mysite.co.uk version, will the SSL certificate still work or will i have to set the https version as the preferred domain?

Also, once i have worked out which domain is to be the preferred one, what code do i need to put in the .htaccess file? (i am on a linux server)

I hope that all makes sense and i thank you in advance for any help and advice.

Lee
#301 #canonicalization #htaccess #redirect
  • Profile picture of the author UMS
    You effectively have 4 variations for your site:

    2 x http
    2 x https

    One important thing you didn't mention is whether the https pages on your site are unique or a duplicate of all the http pages.

    If the https version of your site is effectively a mirror and you want that to be the preferred version, then your .htaccess file should look something like:

    Code:
    RewriteCond %{HTTPS} off 
    RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]  
    
    RewriteCond %{HTTPS} on
    RewriteCond %{HTTP_HOST} !^www.(.*)$ [NC]
    RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]
    {{ DiscussionBoard.errors[8643983].message }}
    • Profile picture of the author sublimino
      Many thanks for the reply!

      Yes - the https is a duplicate of the regular http i believe.

      I just installed the ssl on the domain so the whole site is accessible via http or https. Is that what you mean?

      Many thanks for the code for the .htaccess file!
      {{ DiscussionBoard.errors[8646132].message }}

Trending Topics