Domain Discussion Board

Go Back   Domain Discussion Board > General > Tutorials

 
Reply
 
LinkBack Thread Tools Display Modes
How to tempt Google to index your Site despite redirection
Old
  (#1 (permalink))
blue-sky
Senior Member
blue-sky is an unknown quantity at this point
 
Status: Offline
Posts: 238
Points: 52.5
Bank: 6,643.0
Total Points: 6,695.4
Donate
Join Date: Nov 2006
Rep Power: 0
How to tempt Google to index your Site despite redirection - 11-25-2006, 11:43 PM

How to tempt google to index your site despite redirection.



This short tutorial shows you how to redirect UserAgents with PHP and still getting indexed by Google!


/dev/google

At a first glance it seems like there is nothing on the web, that can hide from beeing indexed by Google. Not only html but twelve(!) other filetypes are getting indexed at the moment.
But Google is much pickier as one could assume, whereas its reasons are evident and reasonable:


1. Redirects
Googlebot (Google's Spider) doesn't follow the "http/1.1 302 Found" status code (resource temporarily moved). Instead you should use a "http/1.1 301 Moved Permanently" header to make Google follow the redirect.
To make the long story short: If you're using PHP to do the redirect (and many are using PHP these days) you should add the status code header manually because PHP sends a 302 Found status code by default.

This stops Google and therefore is only usefull if your site is really under maintenance at the moment:
<?php
header
('Location: http://www.foo.com/bar/');
?>

This makes Google follow the redirect and index the Site: <?php
header
('HTTP/1.1 301 Moved Permanently');
header('Location: http://www.foo.com/bar/');
?>

If you prefer to do the redirects within an .htaccess file (on Apache, of course), you could do it like this. Every Request to foo.com/ is redirected to foo.com/bar/: #Redirect (this will result in a 301 permanently moved status code)
RedirectMatch permanent ^/$ http://www.foo.com/bar/

I expect it's faster and less resource intensive to set up an .htaccess file because there is no need to parse any php code at all. Though it won't matter in most cases anyway. (untested assumption)

2. Sessions
Google doesn't follow links with a session attached. If you've enabled session.use_trans_sid in your php.ini you should check if Google is requesting the page. If your site displays fine without the use of sessions simply don't start one if google is visiting. ;-)
<?php
// session is not started to serve google
if( stristr( $_SERVER['HTTP_USER_AGENT'], 'google') === false )
{
session_start();
}
?>

Add as many search engine bots as you like. A more sophisticated method (like regular expressions) is not needed here, but would of course work, too.

Last edited by blue-sky : 11-25-2006 at 11:47 PM.
   
Reply With Quote
Re: How to tempt Google to index your Site despite redirection
Old
  (#2 (permalink))
Sava
Sava is an unknown quantity at this point
 
Sava's Avatar
 
Status: Offline
Posts: 1,522
Points: 18.0
Bank: 5,220.2
Total Points: 5,238.2
Donate
Join Date: Nov 2006
Location: http://savasplace.com
Rep Power: 0
Re: How to tempt Google to index your Site despite redirection - 11-26-2006, 09:42 AM

that's very very nice . Thanks for the tip, maybe it will be usefull if I move my site
   

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Points Per Thread View: 1.0
Points Per Thread: 15.0
Points Per Reply: 5.0


Similar Threads
Thread Thread Starter Forum Replies Last Post
For good or evil, Google grows canadianus Chit-Chat Area - Internet Related 48 08-10-2008 05:19 AM
60 sites for sale nexmax Web Sites For Sale 44 02-12-2008 12:25 AM
Lucha Entre Google, Microsoft y Yahoo Shaoran Tecnologia Web General 15 04-17-2007 07:32 AM
Submit Ur Site To Google andrew Tutorials 19 03-12-2007 03:53 AM
8 websites for sale! egtrix Web Sites For Sale 3 05-01-2006 09:30 AM


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 ©2007, Crawlability, Inc.