Link Masking or URL Redirects

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

By sidcam - December 10, 2012

I'm downloading MLS real estate listing data to my CMSB site. Three of the fields allow the listing agents to post URL's to externally hosted unbranded virtual tours, property videos, etc. The content is nice for people visiting the site, but I don't suspect they're good for my site's SEO- the outbound URL's are long and ugly and the content is seldom, if ever, indexed.

Example: http://idx.imprev.net/03782F07/10/59910/1739964/index.ipv

I was thinking it might make sense to try and hide the URL's with a redirect or masking script. Thoughts? Any ideas on how it could be done in CMSB?

The solutions I'm finding online are mostly designed for affiliate marketing and require a lot of manual set up to map the fields. Because I'm dealing with thousands of records that change daily I have to have a fully automated solution that just knows a link to "mysite.com/redirect/<records-mls-number>-1/" (or a shortened URL that's coded to say the same thing) searches for the record with the matching mls-number then redirects to the data in the field <virtual-tour1>, etc.

Has anyone done anything like this? Is it even worth worrying about?

Thanks, Sid

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