Ex Google Employee Reveals Just How Easy It Is To Make Money!
JLForums.com Exclusive Special Offers

Author Topic: Setting up Preffered Domain and doing a Site Wide Re-direct  (Read 705 times)

0 Members and 1 Guest are viewing this topic.

Offline evilknevilTopic starter

  • Trade Count: (0)
  • Posting Member
  • *
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 21
    • View Profile
    • Email
    • Awards
Setting up Preffered Domain and doing a Site Wide Re-direct
« on: December 19, 2011, 03:30:36 PM »
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:http://example.com  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:http://www.example.com   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:http://example2.com or site:http://www.example2.com  results ONLY SHOW for example site:http://www.example2.com but NOT for site:http://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 ssome 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.. ;)
"Somedays you're the pigeon, somedays you're the statue"

Offline videomike

  • Trade Count: (0)
  • Hero Member
  • *****
  • Thank You
  • -Given: 0
  • -Receive: 10
  • Posts: 753
    • View Profile
    • SEO Traffic guide
    • Awards
Re: Setting up Preffered Domain and doing a Site Wide Re-direct
« Reply #1 on: December 19, 2011, 04:12:35 PM »
Hi

I think there are two possible explanations:
1) The index is not up to date and does not yet reflect all your redirects
2) there is an error in your redirecting

You can easily test by entering one of the results that still look odd in your browser adress bar. If your redirect code for that particular result is correct, you should be redirected...

Mike

Offline evilknevilTopic starter

  • Trade Count: (0)
  • Posting Member
  • *
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 21
    • View Profile
    • Email
    • Awards
Re: Setting up Preffered Domain and doing a Site Wide Re-direct
« Reply #2 on: December 19, 2011, 04:19:46 PM »
Do you understand what I am saying though?

Should I not ONLY see results under one site: query ??

So when I search for site:http://example.com and site:http://www.example.com  should I not ONLY see results show up under one of those?

Thats what I am trying to figure out?  It is a fairly bif website--but now I am confused to as wether my .htaccess code is ok or not?

Yo know what I mean?
"Somedays you're the pigeon, somedays you're the statue"


Offline Jonathan Leger

  • Administrator
  • Trade Count: (0)
  • Hero Member
  • *****
  • Thank You
  • -Given: 6
  • -Receive: 258
  • Posts: 5695
  • Here's to your success!
    • View Profile
    • Jonathan Leger's Blog
    • Awards
Re: Setting up Preffered Domain and doing a Site Wide Re-direct
« Reply #3 on: December 19, 2011, 04:24:41 PM »
What kind of redirect are you using? It should be a 301 Moved Permanently redirect.

Sent from my LG-MS910 using Tapatalk

Offline evilknevilTopic starter

  • Trade Count: (0)
  • Posting Member
  • *
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 21
    • View Profile
    • Email
    • Awards
Re: Setting up Preffered Domain and doing a Site Wide Re-direct
« Reply #4 on: December 19, 2011, 04:31:19 PM »
It is set to do a 301 redirect, from what I know of it...I am not an expert on the setup of redirects and like I said, my code looks different than most online to re-direct.

Do you mind I post my redirect code (minus my actual domain name?)
"Somedays you're the pigeon, somedays you're the statue"

Offline Jonathan Leger

  • Administrator
  • Trade Count: (0)
  • Hero Member
  • *****
  • Thank You
  • -Given: 6
  • -Receive: 258
  • Posts: 5695
  • Here's to your success!
    • View Profile
    • Jonathan Leger's Blog
    • Awards
Re: Setting up Preffered Domain and doing a Site Wide Re-direct
« Reply #5 on: December 19, 2011, 04:38:54 PM »
Go ahead. I'm not an expert, but I've done this kind of redirect before.

Sent from my LG-MS910 using Tapatalk

Offline evilknevilTopic starter

  • Trade Count: (0)
  • Posting Member
  • *
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 21
    • View Profile
    • Email
    • Awards
Re: Setting up Preffered Domain and doing a Site Wide Re-direct
« Reply #6 on: December 19, 2011, 04:54:35 PM »

So like I said, I set up the 'preffered domain' in webmaster tools, then I put this at the top of my .htaccess file



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



What I don't understand is why most redirect code I have seen online only has (.*) once for the RewriteRule and not the RewriteCond ?

I did get this code off of some well known marketers website. (I'm just not sure if this is an error?) Maybe he made a mistake in the code...?

The second RewriteCond & RewriteRule is something I just added the other day...
"Somedays you're the pigeon, somedays you're the statue"

Offline Jonathan Leger

  • Administrator
  • Trade Count: (0)
  • Hero Member
  • *****
  • Thank You
  • -Given: 6
  • -Receive: 258
  • Posts: 5695
  • Here's to your success!
    • View Profile
    • Jonathan Leger's Blog
    • Awards
Re: Setting up Preffered Domain and doing a Site Wide Re-direct
« Reply #7 on: December 19, 2011, 06:20:53 PM »
Hmmmm. And it's redirecting fine in the browser? How long has the code been live on the site? Perhaps Jorge is correct and Google hasn't updated their index yet.

Sent from my LG-MS910 using Tapatalk

Offline evilknevilTopic starter

  • Trade Count: (0)
  • Posting Member
  • *
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 21
    • View Profile
    • Email
    • Awards
Re: Setting up Preffered Domain and doing a Site Wide Re-direct
« Reply #8 on: December 19, 2011, 06:50:05 PM »
Yea, from what I see....seems to redirect when I type in examplesite.com - it redirects to www.examplesite.com

*This code has been live for at least 4 months I would say..


#1.) I don't see why I am getting listings for site:http://examplesite.com  and site:http://www.examplesite.com  - I thought, based on my other websites that I would only have results show under one of those queries..

I can PM you the site address if you want to see what I mean...I don't get it...
My rank on this website had dropped with the whol;e Panda thing, this is when I decided to investigate. I learned about setting the preferred domain and then using a 301 sitewide redirect to point the urls to the preferred choice.

I went from a pr5 website, down to a pr3 and the site is probably 200 pages in size...

Very frustrating trying to get this set right..
"Somedays you're the pigeon, somedays you're the statue"


Offline Jonathan Leger

  • Administrator
  • Trade Count: (0)
  • Hero Member
  • *****
  • Thank You
  • -Given: 6
  • -Receive: 258
  • Posts: 5695
  • Here's to your success!
    • View Profile
    • Jonathan Leger's Blog
    • Awards
Re: Setting up Preffered Domain and doing a Site Wide Re-direct
« Reply #9 on: December 19, 2011, 07:24:19 PM »
Even with a PR3 it's unlikely that Google just hasn't updated their index yet -- unless they are choosing not to do so for some reason. I don't think looking at the site itself would really matter. If it redirects in a browser, and it's a 301, then it should update in the index. If it's not then there's some other issue, but I couldn't tell you what it is.

Offline evilknevilTopic starter

  • Trade Count: (0)
  • Posting Member
  • *
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 21
    • View Profile
    • Email
    • Awards
Re: Setting up Preffered Domain and doing a Site Wide Re-direct
« Reply #10 on: December 19, 2011, 08:38:13 PM »
unlikely or likely?....that google hasn't updated their indexes..?

does that redirect code look normal for the .htaccess code? maybe that bit of code saying (.*) is causing the issue.

am i gonna create issues if i change the .htaccess code to another more common code that i am finding online?


"Somedays you're the pigeon, somedays you're the statue"

Offline videomike

  • Trade Count: (0)
  • Hero Member
  • *****
  • Thank You
  • -Given: 0
  • -Receive: 10
  • Posts: 753
    • View Profile
    • SEO Traffic guide
    • Awards
Re: Setting up Preffered Domain and doing a Site Wide Re-direct
« Reply #11 on: December 20, 2011, 09:46:55 AM »
Hi Evilknevil

I am pretty sure I understood you right. The suggested test would have shown you whether your redirect code works as intended.
And for URLs like exampledomain.com it should work.
It looks a bit more complicated than it needs to be for me and this has a backdraft that you probably have not intended.
Your rewrite condition tells the server to use the rule on every URL that does not match the pattern something.exampledomain.com and then do the rewrite rule. If someone enters just http://exampledomain.com that does not match something.exampledomain.com and will be redirected.
All fine.
Now what happens if someone made a mistake in their link and used ww.exampledomain.com (one w missing...)?
That will match the pattern and as the rule says rewrite only if it does not match the pattern, the URL will not be redirected.
What happens next depends on the configuration of the web server. If it has a wildcard match then anything.exampledomain.com will be served the content in your web root directory and you have the duplicate issue again that you wanted to avoid.
if you do not have any other subdomains on that domain then a good conditon woould be
RewriteCond %{HTTP_HOST} !^www\.examplewebsitehere\.com$ [NC]
instead of the
RewriteCond %{HTTP_HOST} !^(.*)\.examplewebsitehere\.com$ [NC]

This will redirect in all cases that the URL is not the www. version.
This ia not possible if you have a subdomain like myblognumber2.exampledomain.com

If you want you can also PM the URL and I will have a look.

Mike

Follow members gave a thank to your post:


Offline evilknevilTopic starter

  • Trade Count: (0)
  • Posting Member
  • *
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 21
    • View Profile
    • Email
    • Awards
Re: Setting up Preffered Domain and doing a Site Wide Re-direct
« Reply #12 on: December 20, 2011, 11:43:23 AM »
OK MIke,

Thanks...that helps alot...I thought there was something weird happening. I think I understand better now.

Now I have a Forum and a Blog for this website. They are of course listed each under their own directory-but that isn't a subdomain and won't affect them negatively then correct?

The .htaccess code that you showed is the code I have been seeing everywhere. Mine was different with the extra instance of (.*)

I am going to go ahead and PM you...I not really sure if my secondary rewrite and cond is placed correctly. I think it is..but need to be sure.

This helps me..and in turn, saves what little hair I have left! :)

Keep on the lookout for PM...
"Somedays you're the pigeon, somedays you're the statue"

Offline evilknevilTopic starter

  • Trade Count: (0)
  • Posting Member
  • *
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 21
    • View Profile
    • Email
    • Awards
Re: Setting up Preffered Domain and doing a Site Wide Re-direct
« Reply #13 on: December 20, 2011, 11:55:38 AM »
So, for the sake of educating the masses...I will show you my current .htaccess redirect code (urls removed and substituted) this way I guess others can learn by my example and the help in this thread.

The following is the .htaccess code as it sits now for redirection:
----------------------------------------------------------------------------------


DirectoryIndex index.htm
RewriteEngine On
RewriteCond %{HTTP_HOST} !^(.*)\.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]

<IfModule mod_headers.c>
<FilesMatch "\.(ico|gif|jpg|jpeg|png|flv|pdf|swf|mov|mp3|wmv|ppt)$">
   ExpiresDefault A2419200
   Header append Cache-Control "public"
</FilesMatch>

<FilesMatch "\.(html|htm)$">
   Header set Cache-Control "max-age=1209600, must-revalidate"
</FilesMatch>

<FilesMatch "\.(js|css|xml|gz)$">
   Header append Vary Accept-Encoding
</FilesMatch>
</IfModule>

<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault A1209600
ExpiresByType image/gif A2419200
ExpiresByType image/png A2419200
ExpiresByType image/jpeg A2419200
ExpiresByType image/x-icon A2419200
ExpiresByType application/x-javascript A2419200
ExpiresByType text/css A2419200
ExpiresByType text/html A1209600
</IfModule>


------------------------------------------------------------------------------------------------------

* I left the IfModule info in there as well even though it doesn't pertain to redirection.  I just need to be sure that it is not going to affect the redirection code in question at the top.

Not sure if this is proper structure of the .htaccess commands but I beleieve it is ok, other than the code in question at the top.

"Somedays you're the pigeon, somedays you're the statue"

Offline evilknevilTopic starter

  • Trade Count: (0)
  • Posting Member
  • *
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 21
    • View Profile
    • Email
    • Awards
Re: Setting up Preffered Domain and doing a Site Wide Re-direct
« Reply #14 on: December 21, 2011, 10:54:56 AM »

*So then, just for the sake of confirming the code and everyone seeing this thread learning. My code then for my .htaccess should now look like this below? This will then redirect ALL 'non-www' versions of my website to 'www' versions ??

---------------------------------------------------------------------------------------------------

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]

<IfModule mod_headers.c>
<FilesMatch "\.(ico|gif|jpg|jpeg|png|flv|pdf|swf|mov|mp3|wmv|ppt)$">
   ExpiresDefault A2419200
   Header append Cache-Control "public"
</FilesMatch>

<FilesMatch "\.(html|htm)$">
   Header set Cache-Control "max-age=1209600, must-revalidate"
</FilesMatch>

<FilesMatch "\.(js|css|xml|gz)$">
   Header append Vary Accept-Encoding
</FilesMatch>
</IfModule>

<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault A1209600
ExpiresByType image/gif A2419200
ExpiresByType image/png A2419200
ExpiresByType image/jpeg A2419200
ExpiresByType image/x-icon A2419200
ExpiresByType application/x-javascript A2419200
ExpiresByType text/css A2419200
ExpiresByType text/html A1209600
</IfModule>

----------------------------------------------------------------------------------
"Somedays you're the pigeon, somedays you're the statue"