Jump to content

SESSION variable creating a loop with bots SEO problem


samoht

Recommended Posts

Hello all,

 

I need help with a session var.

<?php
session_start();

//check for searchengine bots and send them to the default USA page
$agent = strtolower($_SERVER['HTTP_USER_AGENT']);
$bots = array ('googlebot','msn','slurp','scooter','scrubby');
foreach ($bots as $bot)
{
if(strstr($agent, "$bot"))
{
	$_SESSION['country'] = "USA Website";
	header( "HTTP/1.1 301 Moved Permanently" ); 
	header ('Location: http://www.mysite.com');   
}
}

//check if the location is set - if so redirect
if(isset($_POST['location']) && !isset($_SESSION['country'])){
$_SESSION['country'] = $_POST['location'];
header( "HTTP/1.1 301 Moved Permanently" ); 
header ('Location: http://www.mysite.com');
}

//session var is set so view the whole page
if(isset($_SESSION['country'])){
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>" dir="<?php echo $this->direction; ?>" >
<head>
...
<?php
//session not set so view the form to select location
}else{
?>
<html>
<head>
<meta http-equiv="Content-Language" content="en-us" />
<title>mysite Spine Choose Your Site</title>
</head>

...
<?php
}
?>

 

for some reason this produces a "Forbidden Access"  (Flooding) error?

 

How can I send the bots safely to the site without this issue??

 

Thanks for any help.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.