• Howdy! Welcome to our community of more than 130.000 members devoted to web hosting. This is a great place to get special offers from web hosts and post your own requests or ads. To start posting sign up here. Cheers! /Peo, FreeWebSpace.net
managed wordpress hosting

Php seo


Well-Known Member
Okay, one simple idea.

$qstring = stripslashes($_SERVER['QUERY_STRING']);
if($qstring == '')$robots = '<meta name="robots" content="index,follow,noarchive" />';
else $robots = '<meta name="robots" content="noindex,nofollow,noarchive" />';
echo $robots;

So if you have somepage.php only the naked version will index in search engines - that is, any that have a query string like somepage.php?lang=de etc will not index.

If you have a dedicated IP you can also prevent indexing on the IP as such:

$httphost = $_SERVER['HTTP_HOST'];
$qstring = stripslashes($_SERVER['QUERY_STRING']);
if($qstring != '' || $httphost == '')$robots = '<meta name="robots" content="noindex,nofollow,noarchive" />';
else $robots = '<meta name="robots" content="index,follow,noarchive" />';
echo $robots;
Okay so here's another SEO-friendly idea. What if your error document could automatically forward your visitors to the correct URL? Most pages are all in lowercase, here is one way to redirect visitors using 301 if they accidently typed a capital into the URL. This will of course work for all filetypes, gif, png, mp3, txt, zip, exe, etc.

$reqname = strtolower(strtok($_SERVER['REQUEST_URI'],'?'));
$fname = $_SERVER{'DOCUMENT_ROOT'}. $reqname;
$base_url ='http://'. $_SERVER['HTTP_HOST']. $reqname;
if(file_exists($fname)){ header("HTTP/1.0 301 Moved Permanently");
Header('Location: '. $base_url); 
<TITLE>301 Moved Permanently</TITLE>
<H1>Moved Permanently</H1>
The document has moved <A HREF="<?=$base_url;?>">here</A>.<P>
}else{ header("HTTP/1.0 404 Not Found");
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/2002/REC-xhtml1-20020801/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
<link rel="icon" href="/favicon.ico" type="image/vnd.microsoft.icon" />
<base target="_top" href="<?=$base_url;?>" />
<title>404 Not Found</title>
<h1>404 Not Found</h1>
<p>The requested URL <? echo $_SERVER['REQUEST_URI']; ?> was not found on this server.</p>

Now the 404 document is doing a little bit more work for you before it sends people the 404 message.
Last edited: