Setting a Preferred Domain and sitewide .htaccess ReDirect

6 replies
Hello guys & Gals..


As I'm sure most of you know, if you don't set up a 'preferred domain' in Google Webmaster tools for when people search your site, you could end up splitting your backlinks between the 2 version of your website namely 'www' and 'non-www'

In other words, for those who may not fully know what I am talking about, your website COULD be viewed upon as actually being 2 different websites.

Here Is My Question for those of you who are familiar with this optimization method,

I have set up my 'preffered domain' in Web Master Tools.

I have also set up a 'site wide redirect' (or so I believe I have) in my .htaccess file

In other words, when people search typing 'example.com' that should re-direct to 'www.example.com'

Or when people search using 'example.com/examplepage.html' it should re-direct to 'www.example.com/examplepage.html'

My findings:

It appears to redirect when I leave off the 'www' to my preffered domain. I assume this is correct. I also assume my .htaccess re-direct code is correct.

However - Here is where I am confused:

When i do a site:IANA — Example domains in Google, I get a list of various pages with my preffered domain and some pages that are NOT my preferred domain.

When I do site:IANA — Example domains in Google, I get basically the same list of pages (maybe a few more or less results)


Is this the way it should be? Does this seem like the re-direct and preffered domain are set correctly?


**The reason I am confused is I have other websites that in which a 'preferred domain' was set and when I use the site:example2.com or site:example2.com results ONLY SHOW for example site:example2.com but NOT for site:example2.com


Any ideas what is happening? I really need to be sure that all my links are going to one specific or 'preffered domain'


Can anyone shed some light just to clear this up for me so I know 100% that it is set correctly?

My .htaccess code is a slight bit different looking than all the other .htaccess redirect code I have found online- I can post if requested...

Thanks in advance for your thoughts..
#.htaccess #domain #htaccess #preferred #preferred domain #redirect #setting #sitewide #sitewide redirect
  • Profile picture of the author RobKonrad
    Hey EvilKnevil,

    I thing this issue is not really something you will need to worry about.

    Simple reason: If you build your backlinks to www.sampledomain.com, they will point at www.sampledomain.com, if you build them to sampledomain.com, they will point to sampledomain.com, period.

    So if you don't want a mixup, make sure your backlinking campaigns do either www or not, and you're good.

    Cheers,
    Rob
    Signature
    ================================================== ===
    This blog is awesome: http://www.robkonrad.com/blog. Read it.
    ================================================== ===
    {{ DiscussionBoard.errors[5269528].message }}
    • Profile picture of the author EvilKnevil
      The issue is, that I need to be sure. when I started this website years ago, I obviously had all sorts of links pointing to different variations of the url.

      If Google treats 'www' and non-www' urls as separate websites that means it also splits my backlinks between the 2.

      I want to use 'www' version and have made that the preferred version in Google Webmaster Tools.

      The issues comes in with my .htaccess code for redirecting all non-www backlinks to www.

      Obviously if I can do this it is going to benefit my website from a backlink perspective.

      I just do not know if my .htaccess code is correct-it appears to be a bit different than most redirect code I see online.

      It has 2 instances of (.*) Where as most I see online only have one instance of that.

      When I do a site:IANA — Example domains & a site:IANA — Example domains I get listings for both.

      Shouldn't one show no results???

      * I really need someone who understands this to help me out here guys! I really have to get this right and be sure..

      I appreciate ALL your help everyone..

      Any ideas or thoughts???? (I can post my exact redirect code if that helps)
      {{ DiscussionBoard.errors[5271121].message }}
      • Profile picture of the author Maraun
        You have to do 301 redirects. This tells the search engine that the site has permanently moved to the new target, passing on the link power of all links from the old URL to the new one. If you set that up, and it technically works, then you can only wait for Google to pick up on that. I have done that myself moving an entire blog from blogspot to a private domain. I have put 301 redirects for all pages on the blogspot blog to the private server and after a few weeks it only showed the new domain in the SERPS.
        {{ DiscussionBoard.errors[5277781].message }}
  • Profile picture of the author sultanmehmet02
    i use to do it befroe but catn remember how :s
    Signature
    {{ DiscussionBoard.errors[5280760].message }}
    • Profile picture of the author EvilKnevil
      Yes, I realize that. I am trying to figure out if the following code is correct in its structure and redirecting ALL 'non-www' to 'www' versions of the website.

      ================================================== =========
      DirectoryIndex index.htm
      RewriteEngine On
      RewriteCond %{HTTP_HOST} !^www\.examplesite\.com$ [NC]
      RewriteRule ^(.*)$ http://www.examplesite.com/$1 [R=301,L]
      RewriteCond %{THE_REQUEST} /index\.htm [NC]
      RewriteRule ^(.*/)?index\.htm$ /$1 [R=301,L]

      IndexIgnore *

      ================================================== ==========

      Thanks in advance for your input...
      {{ DiscussionBoard.errors[5285849].message }}
  • Profile picture of the author IM-software
    To concentrate the "juice", it is recommended to either redirect the sub-domain www to the root domain, or vice-versa, with a 301.

    Most of the time the root domain is redirected to the sub-domain www.

    Given that you opt for the above, if you don't have files on the root domain, you may redirect only its root index.php this way:
    header("HTTP/1.1 301 Moved Permanently");
    header("Location: http://www.thesite.com");

    Eventually with this root collector .htaccess:

    DirectoryIndex index.php
    ErrorDocument 400 /index.php
    ErrorDocument 401 /index.php
    ErrorDocument 403 /index.php
    ErrorDocument 404 /index.php
    Options -Indexes

    If you already have files (pages) on the root domain, given that they get the very same name on both sides, you may use in every file of the root domain:
    header("HTTP/1.1 301 Moved Permanently");
    header("Location: http://www.thesite.com" . $_SERVER["REQUEST_URI"]);

    Remember that *nix are case sensitive.
    {{ DiscussionBoard.errors[5294189].message }}

Trending Topics