473,394 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Getting a redirect to be nofollow ?

290 100+
Hi,

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


Expand|Select|Wrap|Line Numbers
  1.   $sql = "SELECT ad_link FROM adverts WHERE advert_id = $N_ad_id";
  2.      $result = mysql_query($sql)    or die("could not execute find PRODUCTS query". mysql_error());  
  3.          $num = mysql_num_rows($result);
  4.  
  5.          if ($num == 0 ) {
  6.          echo "There an ERROR in locating this product.";
  7.        }  // endif    
  8.          else{       
  9.             $row = mysql_fetch_assoc($result);
  10.                 $N_ad_link = "http://".$row["ad_link"];
  11.  
  12. $sql = "UPDATE adverts SET click_cnt = click_cnt+1 WHERE advert_id = $N_ad_id";
  13. mysql_query($sql) or die("could not execute adverts update query". mysql_error());
  14.  
  15. header("Location: $N_ad_link");
  16. exit(); 
  17.  
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

Expand|Select|Wrap|Line Numbers
  1. $sql = "UPDATE adverts SET click_cnt = click_cnt+1 WHERE advert_id = $N_ad_id";
  2. mysql_query($sql) or die("could not execute adverts update query". mysql_error());
  3.  
  4. echo "
  5. <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"
  6.  \"http://www.w3.org/TR/html4/loose.dtd\">
  7.  
  8. <html>
  9. <head>
  10. <title>Temp Page</title>
  11. <meta name=\"allow-search\" content=\"no\">
  12. <meta name=\"robots\" content=\"all, noindex, nofollow\">
  13. </head>
  14. <body>
  15. header(\"Location: $N_ad_link\");
  16. </body>
  17. </html>";
  18.  
  19. exit(); 
  20.  
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:

Expand|Select|Wrap|Line Numbers
  1. echo "<html>
  2. <head>
  3. <title>Temp Page</title>
  4. <meta name=\"allow-search\" content=\"no\">
  5. <meta name=\"robots\" content=\"all, noindex, nofollow\">
  6. <meta http-equiv ='refresh' content = '0;url = $N_ad_link'>
  7. </head>
  8. <body>
  9. </body>
  10. </html>";
Is this a better method ?
Mar 14 '09 #1
4 3025
Markus
6,050 Expert 4TB
Second example will you a 'headers already sent' error.

I believe setting the header to a 301 redirect will discourage spiders from indexing it - 301 is a permanent move. I may be wrong.

Expand|Select|Wrap|Line Numbers
  1. header( "HTTP/1.1 301 Moved Permanently" ); 
  2. header( "Location: ..." );
  3.  
Mar 14 '09 #2
jeddiki
290 100+
Thanks for your reply,

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:

Expand|Select|Wrap|Line Numbers
  1. require_once("my_functions.php");
  2.  
  3. $today = date("U");
  4.  
  5. if(isset($_GET["a"])){                          
  6.     $N_ad_id = safe_sql($_GET["a"]);
  7.  
  8.       $sql = "SELECT ad_link FROM adverts WHERE advert_id = $N_ad_id";
  9.      $result = mysql_query($sql)    or die("could not execute find PRODUCTS query". mysql_error());  
  10.          $num = mysql_num_rows($result);
  11.  
  12.          if ($num == 0 ) {
  13.          echo "There an ERROR in locating this product.";
  14.        }  // endif    
  15.          else{       
  16.             $row = mysql_fetch_assoc($result);
  17.                 $N_ad_link = "http://".$row["ad_link"];
  18.  
  19.      // update database
  20.        $sql = "UPDATE adverts SET click_cnt = click_cnt+1 WHERE advert_id = $N_ad_id";
  21.          mysql_query($sql) or die("could not execute adverts update query". mysql_error());
  22.  
  23. echo "<html>
  24. <head>
  25. <title>Temp Page</title>
  26. <meta name=\"allow-search\" content=\"no\">
  27. <meta name=\"robots\" content=\"all, noindex, nofollow\">
  28. <meta http-equiv ='refresh' content = '0;url = $N_ad_link'>
  29. </head>
  30. <body>
  31. </body>
  32. </html>";  
  33.      exit();
  34.      } // end else
  35. } // endif
  36. echo "No Link data !! - please inform admin";
  37.  
  38. ?>
Do you see any problems with this ?

( I don't think headers sent earlier will be a problem as this is a new page,
unless I misunderstood )

Thanks
Mar 15 '09 #3
jeddiki
290 100+
Hi Marcus ( or anyone else)

What did you think of this as a solution ?

Have I misunderstood anything ?
Should it work OK ?
Mar 18 '09 #4
Markus
6,050 Expert 4TB
@jeddiki
Sure, if it works for you, then ok. But it's more code that what is necessary; the page loading the html isn't needed, and will just make it a tad slower. I'm pretty sure my post above would prevent spiders from following the redirect.
Mar 18 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: deko | last post by:
I'm trying to create a very basic login page that will redirect a logged in user to a secure page. I set the session_start variable at the top of the login page, then redirect to securePage.php if...
5
by: Steve Lutz | last post by:
Hello, I have a page that creates a class, and then on certain conditions, redirects user to another page. The class has a Class_Terminate() function that saves itself to a database. The class...
3
by: Steve Mauldin | last post by:
This is a standard ASP application that has several pages at the root withthe global.asa. I set a session variable session("accountid") = "123456" within an asp page and then response.redirect to...
2
by: alex p | last post by:
I have create a website that links to other websites, using a response.redirect("URL_OF_WEBSITE") For some reason I have managed to get on top at Google, with these pages that only redirect to a...
0
by: Philipp Lenssen | last post by:
There's a new quasi-standard in the world of HTML; the <a rel="nofollow" href="...">...</a>. It is already or soon implemented in Google, Yahoo, and MSN Search, as well as many different blogging...
5
by: Adam Clauss | last post by:
I have a webapp which consists of several different webforms. Basically: (1) view the contents of a database (2) one is to add a new entry (3) confirms the new entry. The third form, upon...
2
by: needin4mation | last post by:
I remember in 1.1 that I would put not to populate a given dropdownlist unless it was not Page.IsPostBack. But in 2.0 where I use the DAL and no codefile, I don't see where to effect this. Any...
6
by: David Lozzi | last post by:
Hello there, I'm getting the following error System.NullReferenceException: Object reference not set to an instance of an object. at shopping_bag.GetBagTotals()
2
by: FFMG | last post by:
Hi, I run a blog hosting site and it is a fairly small community easy enough to police. But some spammers still find ways to get in. What I was thinking is adding nofollow tags to their links...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.