Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Senior Coder
    Join Date
    May 2006
    Posts
    1,680
    Thanks
    28
    Thanked 4 Times in 4 Posts

    Getting a redirect to be nofollow ?

    Hi,

    I am using a dynamic redirect to take vistors to the database stored
    url as in this part of the script:


    PHP Code:
      $sql "SELECT ad_link FROM adverts WHERE advert_id = $N_ad_id";
         
    $result mysql_query($sql)    or die("could not execute find PRODUCTS query"mysql_error());  
             
    $num mysql_num_rows($result);

             if (
    $num == ) {
             echo 
    "There an ERROR in locating this product.";
           }  
    // endif    
             
    else{       
                
    $row mysql_fetch_assoc($result);
                    
    $N_ad_link "http://".$row["ad_link"];
        
    $sql "UPDATE adverts SET click_cnt = click_cnt+1 WHERE advert_id = $N_ad_id";
    mysql_query($sql) or die("could not execute adverts update query"mysql_error());

    header("Location: $N_ad_link");
    exit(); 
    Now I want to ensure that search engine robots and web crawlers do not
    index these links. Can I insert a bit of html code to accomplish this ?

    EG

    PHP Code:
    $sql "UPDATE adverts SET click_cnt = click_cnt+1 WHERE advert_id = $N_ad_id";
    mysql_query($sql) or die("could not execute adverts update query"mysql_error());

    echo 
    "
    <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"
     \"http://www.w3.org/TR/html4/loose.dtd\">

    <html>
    <head>
    <title>Temp Page</title>
    <meta name=\"allow-search\" content=\"no\">
    <meta name=\"robots\" content=\"all, noindex, nofollow\">
    </head>
    <body>
    header(\"Location: $N_ad_link\");
    </body>
    </html>"
    ;

    exit(); 
    I have escaped the double quotes because they are inside the
    echo statement.

    Is the header(\"Location: $N_ad_link\"); in the correct place ?
    Do you think this is the best way to do it ?

    Thanks for any advice.

    PS Maybe I should use a meta-refresh instead:

    So in the above html I will put:
    PHP Code:
    echo "<html>
    <head>
    <title>Temp Page</title>
    <meta name=\"allow-search\" content=\"no\">
    <meta name=\"robots\" content=\"all, noindex, nofollow\">
    <meta http-equiv ='refresh' content = '0;url = $N_ad_link'>
    </head>
    <body>
    </body>
    </html>"

    Is this a better method ?
    Last edited by jeddi; 03-14-2009 at 11:28 AM.

  • #2
    Senior Coder
    Join Date
    May 2006
    Posts
    1,680
    Thanks
    28
    Thanked 4 Times in 4 Posts
    I should mention that with the
    suggestions above, the code is being loaded
    from a .htaccess re-write command.

    So the rewrite is like this:
    RewriteRule ^[\.-a-z]+/bonuses-K([0-9]+)\.html$ ad_linker.php?a=$1 [NC,QSA,L]

    and then the ad_linker.php?a=$1 code
    will look like this:

    PHP Code:
    require_once("my_functions.php");

    $today date("U");

    if(isset(
    $_GET["a"])){                          // Comming from an advert.
        
    $N_ad_id safe_sql($_GET["a"]);

          
    $sql "SELECT ad_link FROM adverts WHERE advert_id = $N_ad_id";
         
    $result mysql_query($sql)    or die("could not execute find PRODUCTS query"mysql_error());  
             
    $num mysql_num_rows($result);

             if (
    $num == ) {
             echo 
    "There an ERROR in locating this product.";
           }  
    // endif    
             
    else{       
                
    $row mysql_fetch_assoc($result);
                    
    $N_ad_link "http://".$row["ad_link"];
        
         
    // update database
           
    $sql "UPDATE adverts SET click_cnt = click_cnt+1 WHERE advert_id = $N_ad_id";
             
    mysql_query($sql) or die("could not execute adverts update query"mysql_error());

    echo 
    "<html>
    <head>
    <title>Temp Page</title>
    <meta name=\"allow-search\" content=\"no\">
    <meta name=\"robots\" content=\"all, noindex, nofollow\">
    <meta http-equiv ='refresh' content = '0;url = $N_ad_link'>
    </head>
    <body>
    </body>
    </html>"
    ;  
         exit();
         } 
    // end else
    // endif
    echo "No Link data !! - please inform admin";

    ?> 
    Do you see any problems with this ?
    Or can suggest a better way ?

    Thanks

  • #3
    Senior Coder
    Join Date
    May 2006
    Posts
    1,680
    Thanks
    28
    Thanked 4 Times in 4 Posts
    Can anyone offer some advice about this please ?

  • #4
    Senior Coder
    Join Date
    May 2006
    Posts
    1,680
    Thanks
    28
    Thanked 4 Times in 4 Posts
    Somebody on another forum suggested that
    I might run into "header trouble" when doing this.

    He did not elaborate.

    Is my solution going to work OK or have
    I mis-understood something ?

    Thanks for any input / advice.


  •  

    Posting Permissions

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