Login to Your Account


Login using your Facebook account

Join the Mercury Community

Click on all the boats to prove you're human.


How To Home | more...

How SEO Translation Works

During the process of analyzing an inbound request Mercury will check to see if there is an SEO translation that should occur.  The goal of SEO translations are to give a developer the ability to easily map any inbound URL to a dynamic page within the Mercury system.

The good news is that what is actually going on here is pretty straightforward.  If Mercury finds a matching SEO file then it will include the file and continue processing the request.  That's it.

Really?  How does that work?

There are two primary reasons that you will likely have SEO translations.  One is to create a completely transparent URL translation.  That means that someone types in /yourpath/yourfilename.html and it might pull up a specific blog post or shopping cart itme.  More on how to do this in a moment.

The other is to perform a browser redirect and actually bounce them to another URL.  This is useful if you want to have a promotional URL that is easy for print but you actually want people to end up on a longer existing URL.

Redirecting the Request

We will use a real life example for this one.  One site running Mercury has a cool augmented reality application that lives on the page: http://www.rayreflected.com/The-Garage.php.  While that is short it was decided that http://www.rayreflected.com/garage would be the URL that would be published on marketing material.  There are several ways to perform a redirect like this but one way to do it with Mercury is described here.

Create a file called html/seo/garage/index.php.  SEO will accept a file called html/seo/garage as well but if you plan to have additional files under the folder you should add index.php to the end.

This file will contain the following code:

<?php
    redirect("http://www.rayreflected.com/The-Garage.php");
?>

That's it!

Creating a Transparent URL Translation

The other technique described above is to take an incoming URL and have Mercury handle it as if another, more complicated URL had been entered.  Mercury pulls all incoming POST and GET varibles into an array called $m.  Additionally two variables can be set to choose which action should be taken.

$module will specify the name of the Mercury module you want to have handle the request.

$action will specify the filename within the module.  Do not specify ".php" as Mercury will add this for you.

Manually specifying these two variables in your SEO file is like having Mercury parse them out of your URL path.  This is another way to do that while creating custom URLs.

A sample file might look like this:

<?php
    $module = "groups";
    $action = "members";
    $m['GroupId'] = 3;
?>

This should give you the same result as a URL like /groups/members?GroupId=3 except you have the freedom to specify what the new URL is completely.  Set this file up in html/seo/myGroup/index.php and tell people the url is now http://www.yourdomain.com/myGroup.