Link Masking or URL Redirects

2 posts by 2 authors in: Forums > CMS Builder
Last Post: December 12, 2012   (RSS)

By gregThomas - December 12, 2012 - edited: December 12, 2012

Hi Sid,

I'm not sure how much of an improvement this would make to your rankings, but if you go ahead with it I would create the redirect system like this:

1)Create a redirect section with a text field for the URL, and a text field called title for the redirect link. Ensure that the title is a unique field and that it can only contain lowercase letters a-z and dashes.
2)Create a directory called redirect and place an index file in it with something similar to this:

<?php /* STEP 1: LOAD RECORDS - Copy this PHP code block near the TOP of your page */

// load viewer library
$libraryPath = 'cmsAdmin/lib/viewer_functions.php';
$dirsToCheck = array('W:/g/greg.com/htdocs/','','../','../../','../../../');
foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }


//get title from url
foreach($_REQUEST as $key => $item){
$title = htmlencode($key);
}

//Check to see if an entry with that title exists in the redirect section
$redirect_entry = mysql_get('redirect', null, "title = '$title'");

if(@$redirect_entry['url']){
redirectBrowserToURL($redirect_entry['url']);
}else{
header("HTTP/1.0 404 Not Found");
}
exit;


Then if you had an entry in your redirect section with a title of go-to-google and a URL of http://www.google.com. You could redirect to this address with the following url:

http://www.mysite.com/redirect/?go-to-google

Thanks

Greg
Greg Thomas







PHP Programmer - interactivetools.com