473,804 Members | 3,162 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Getting a redirect to be nofollow ?

290 Contributor
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(\"Locati on: $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 3050
Markus
6,050 Recognized Expert Expert
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 Contributor
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 Contributor
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 Recognized Expert Expert
@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
26900
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 the user enters the right credentials. The redirect works, but apparently $HTTP_SESSION_VARS is not getting set because I cannot view securePage.php. Am I setting $HTTP_SESSION_VARS correctly? My guess is I'm missing something elementary. ...
5
2199
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 comes from an includes ASP file, it isn't a COM object. Here's my code outline (not actual code for brevity - in otherwords, there may be syntax errors, but that's not the cause of the problem)
3
2336
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 the next page and immediately response.write session("accountid") and I get back nothing. But if I set a session variable session("accountid") = "123456" within an asp page and response.redirect to a page in a sub directory and immediately...
2
2904
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 website of an affiliate program of mine. The problem now is that the affiliate program thinks that Google is the referer instead of me. What can I do to prevent this. Is there a way to somehow alter the change the HTTP_REFERER when I use...
0
1720
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 products. The intent? To battle comment, referrer, and trackback spam. My comments on this are in my blog: Rel Nofollow Details (Introduction) http://blog.outer-court.com/archive/2005-01-19-n46.html Nofollow in Firefox (User-stylesheets)
5
7351
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 confirming the entry (in a button_clicked handler) adds the entry into the database and then redirects back to (2) using Response.Redirect(..)
2
1295
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 help is appreciated. I want my dropdownlist to keep what the use selected when the page refreshes. Thanks.
6
3627
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
2649
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 until they reach a certain amount of posts, (or until I've had time to review their account).
0
9707
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10586
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10338
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10082
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6856
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5525
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5658
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4301
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3823
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.