homepage Welcome to WebmasterWorld Guest from 54.227.62.141
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Pubcon Website
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
redirect script with noindex, nofollow, noarchive
Proper way to accomplish this?
mihomes




msg:4492080
 9:39 pm on Sep 6, 2012 (gmt 0)

Looking to use a php redirect script for my site and I do not want the page to be indexed, followed, archived, etc.

I have disallowed the /goto.php page in my robots.txt, however, Google also states if other sites link to this page it could still be picked up.

To entirely prevent a page's contents from being listed in the Google web index even if other sites link to it, use a noindex meta tag or x-robots-tag. As long as Googlebot fetches the page, it will see the noindex meta tag and prevent that page from showing up in the web index. The x-robots-tag HTTP header is particularly useful if you wish to limit indexing of non-HTML files like graphics or other kinds of documents.


So, is my implementation of the x-robots-tag below correct and will this accomplish what I am looking for?


<?php
/*
Use the following link format:
<a href="/goto.php?p=XXXXXX">XXXXXX</a>
*/

$p = $_GET['p'];

switch ($p)
{

/*widget1*/
case "widget1":
$link = "/widget1.htm";
break;

/*Default*/
default:
$link = "/default.htm";
}

header("X-Robots-Tag: noindex, nofollow, noarchive", true);
header("Location: $link");

exit();
?>

 

g1smd




msg:4492082
 9:48 pm on Sep 6, 2012 (gmt 0)

Use the Live HTTP Headers extension for Firefox to see the actual header your server returns.

You'll also see your redirect is a 302 redirect.

Rather than case statements, the code can be easier to maintain if you use an array for the URL pairs.

mihomes




msg:4492090
 10:05 pm on Sep 6, 2012 (gmt 0)

Thanks g1smd,

Already did that and looks fine :

HTTP/1.1 302 Found
X-Robots-Tag: noindex, nofollow, noarchive
Location: http://www.widgets.com


minus all the other headers.

I guess I was asking more if this would be the preferred method so Google is not indexing the link or passing anything on? This seems a much better method to me than manually adding a rel=nofollow all over the site and makes managing the links much easier.

Would using a 301 perm be better for any reason?

I didn't think about using an array as this was the first thing to pop in my head, but yeah, it would clean it up a bit.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved