Skip to content

Instantly share code, notes, and snippets.

@camt
Created January 22, 2012 08:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save camt/1656247 to your computer and use it in GitHub Desktop.
Save camt/1656247 to your computer and use it in GitHub Desktop.
External redirects from your site trigger web-bots in different ways. If you want to hide them from the web-bots, and have all links on you site point internally, this script is a simple way to do so. You can either run it through a database, which makes
<?php
if(isset($_REQUEST['rd'])) {
$new = $_REQUEST['rd'];
// DB access
include("db.php");
$sql = "SELECT rdURL FROM rd WHERE rdName='".$new." LIMIT 1';";
$result = mysql_query($sql);
mysql_close($conn);
if($result) {
$row = mysql_fetch_array($result);
$newURL = $row['rdURL'];
header("Location: $newURL");
}
else {
header("Location: home.php");
}
}
header("Location: home.php");
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment