Closed Thread
Results 1 to 2 of 2

Thread: Php seo

  1. #1
    NLC Meksilon is on a distinguished road Meksilon's Avatar
    Join Date
    Jan 2002
    Location
    Canberra, Australia
    Posts
    1,147

    Php seo

    Okay, one simple idea.

    PHP Code:
    <?php
    $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:

    PHP Code:
    <?php
    $httphost 
    $_SERVER['HTTP_HOST'];
    $qstring stripslashes($_SERVER['QUERY_STRING']);
    if(
    $qstring != '' || $httphost == '192.168.1.88')$robots '<meta name="robots" content="noindex,nofollow,noarchive" />';
    else 
    $robots '<meta name="robots" content="index,follow,noarchive" />';
    echo 
    $robots;
    ?>

  2. #2
    NLC Meksilon is on a distinguished road Meksilon's Avatar
    Join Date
    Jan 2002
    Location
    Canberra, Australia
    Posts
    1,147
    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.

    PHP Code:
    <?
    $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); 
    ?>
    <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
    <HTML><HEAD>
    <TITLE>301 Moved Permanently</TITLE>
    </HEAD><BODY>
    <H1>Moved Permanently</H1>
    The document has moved <A HREF="<?=$base_url;?>">here</A>.<P>
    </BODY></HTML>
    <?
    }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>
    </head><body>
    <h1>404 Not Found</h1>
    <p>The requested URL <? echo $_SERVER['REQUEST_URI']; ?> was not found on this server.</p>
    </body></html>
    <?
    }
    ?>
    Now the 404 document is doing a little bit more work for you before it sends people the 404 message.
    Last edited by Meksilon; April 25th, 2012 at 05:39.

Closed Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts