...

View Full Version : Getting a redirect to be nofollow ?



jeddi
03-14-2009, 11:19 AM
Hi,

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




$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 == 0 ) {
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



$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:


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 ?

jeddi
03-15-2009, 08:40 AM
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:


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 == 0 ) {
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

jeddi
03-16-2009, 11:50 AM
Can anyone offer some advice about this please ? :)

jeddi
03-18-2009, 08:13 AM
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum