473,915 Members | 5,904 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 3055
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
26925
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
2205
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
2339
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
2905
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
1727
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
7358
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
1296
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
3632
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
2658
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
10039
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
9883
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11359
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
10928
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...
1
11069
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7259
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
6149
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4779
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
3
3370
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.