1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

PHP Help. NoIndexNofollow

Discussion in 'HTML & Website Design' started by BigBadWolf, Dec 8, 2006.

  1. #1
    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 :)
     
    BigBadWolf, Dec 8, 2006 IP
  2. ednit

    ednit Peon

    Messages:
    152
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #2
    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
     
    ednit, Dec 8, 2006 IP
  3. rgchris

    rgchris Peon

    Messages:
    187
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Just for future reference... if you ever want to put HTML in PHP, just echo it out.

    ie. echo '<h1>Title</h1>';
     
    rgchris, Dec 8, 2006 IP
  4. BigBadWolf

    BigBadWolf Well-Known Member

    Messages:
    1,727
    Likes Received:
    67
    Best Answers:
    0
    Trophy Points:
    140
    #4
    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
     
    BigBadWolf, Dec 8, 2006 IP
  5. rgchris

    rgchris Peon

    Messages:
    187
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Just make sure that the php start tag is before the part you echo out.
     
    rgchris, Dec 8, 2006 IP
  6. ednit

    ednit Peon

    Messages:
    152
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #6
    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.
     
    ednit, Dec 8, 2006 IP
  7. BigBadWolf

    BigBadWolf Well-Known Member

    Messages:
    1,727
    Likes Received:
    67
    Best Answers:
    0
    Trophy Points:
    140
    #7
    Thanks for you help guys. It was appreciate. :)
     
    BigBadWolf, Dec 8, 2006 IP
  8. web-spy

    web-spy Active Member

    Messages:
    127
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    93
    #8
    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
     
    web-spy, Dec 8, 2006 IP