Welcome to WebmasterWorld Guest from 54.160.221.82

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

language sorting in php vs.SE spiders

     
11:40 am on Jul 14, 2002 (gmt 0)

New User

10+ Year Member

joined:May 31, 2002
posts:30
votes: 0


Hi
if i want to put in my page some language sorting to sent folks to the their native language versions of my www pages i can do it following way:

<?
switch($HTTP_ACCEPT_LANGUAGE):

case "hr":
include ("indexav.html");
case "bg";
include ("indexae.html");
case "en-au":
include ("indexas.html");
break;
default:
include("indexa.html");
break;
endswitch;
?>

But what about the Search engine spider will they be able to pass the index.php file?

2:46 am on Aug 13, 2002 (gmt 0)

Administrator from US 

WebmasterWorld Administrator brett_tabke is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Sept 21, 1999
posts:38047
votes: 11


*bump* (was posted in the wrong forum).
5:22 am on Aug 13, 2002 (gmt 0)

Preferred Member

10+ Year Member

joined:May 9, 2001
posts:416
votes: 0


Hi vanekpavel,

The answer is in the switch statement.

If the agent (browser or SE bot) doesn't request any of the specified languages then it will default to indexa.html.

As it stands if the browser requests Bulgarian, Croatian, and Australian English the script will try to include indexav.html, indexae.html, and indexas.html. If this isn't what you want insert break; after each of the top two includes. Then the script will serve the index file related to the first request sent, and only that one, or default to indexa.html.

BTW, the last break; (after include("indexa.html");) isn't necessary.

Cheers.