Hey Guys, I have a PHP redirect page that I dont want indexed so I want to slap a NoIndex, Nofollow tag on it. I know how to do this is HTML but not sure how to figure it out in PHP. The redirect is like this: <?php header( 'Location: http://www.yoursite.com/new_page.html' ) ; ?> This doesnt work because it reads the HTML and cause an error. <html> <?php //this will NOT work, the browser received the HTML tag before the script header( 'Location: http://www.yoursite.com/new_page.html' ) ; ?> Thanks
On your server, in the robots.txt file: User-agent: * Disallow: /somefileredirect.php This is not in php, but a compliant search engine robot will obey it. -Rob
Just for future reference... if you ever want to put HTML in PHP, just echo it out. ie. echo '<h1>Title</h1>';
Thanks for the responses guys. Rob could I disallow a whole folder with many redirects in them? ex: User-agent: * Disallow: /folder/ * Is this possible in the robots.txt? Using the echo method the code would be something like this: echo'<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">'; <?php header( 'Location: http://www.yoursite.com/new_page.html' ) ; ?> Is this correct? Thanks
Yes, you can tell the spiders/bots to ignore a particluar folder like this: User-agent: * Disallow: /folder/ You do not need the asterisk after the folder name, though.
if the php page always sends the redirect there is no need for any content on that page, that means you need no html telling to not index there