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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.