Search Engine Safe URLs with Mach-II

Mach-II provides a convenient way to create Search Engine Safe (SES) URLs for your web application without getting your hands dirty.

What are Search Engine Safe (SES) URLs anyway? Typical dynamic pages generated by server-side code require that either FORM or URL-scoped variables be provided in order to differentiate one dynamic page from another. A majority of these URLs look plain ugly: index.cfm?event=welcome&firstName=Adrian&lastName=Scott.

Wouldn’t it be a lot nicer if we got rid of the ?, =, and & symbols in favor of a more structured (and clean) method like: index.cfm/event/welcome/firstName/Adrian/lastName/Scott/. Not only are URLs like this easier to read and understand, but they supposedly also increase search engine optimization.

SEO Consultants – Search Engine Friendly URLs

Mach-II’s SES Functionality

Since version 1.5, Mach-II has provided some simple, yet powerful features which allow you to manage just how you want your SES URLs to work by setting just a few properties.

urlBase String Used to change the base of the url, e.g. index.cfm
urlParseSES Boolean When set to TRUE, Mach-II will parse cgi.path_info for SES data (effectively turns this feature on)
urlDelimiters List (pipe delimited) Defines the URL delimiters used to create the SES URL. First position is the query string delimiter (typically “?”), second position is the series delimiter (typically “&”), and the third position is the pair delimiter (typically “=”)
moduleDelimiter String The delimiter used between the module name and the event name (this cannot be the same as any of the URL delimiters, typically “:”)
eventParameter String Name of the request parameter that will define the event for Mach-II to handle

As per the example above, if you wish to turn index.cfm?event=welcome&firstName=Adrian&lastName=Scott into something like index.cfm/event/welcome/firstName/Adrian/lastName/Scott/, the properties in your Mach-II configuration file will be as follows:

<!-- set up SES URLs -->
<property name="urlParseSES" value="true" />
<property name="urlDelimiters" value="/|/|/" />
<property name="urlBase" value="/index.cfm" />

Mach-II – URL Management Features

Constructing the URLs

Not only does Mach-II help you parse SES URLs, but it also provides you convenient methods to construct them as well. These methods actually take the properties defined in your Mach-II configuration file into consideration when outputting the URLs in question.

For example, if you wanted to create an anchor tag with the new SES URL that you’ve generated above, you could write it out directly like:

<a href="/index.cfm/event/hello/firstName/Adrian/lastName/Scott/">Hello Adrian</a>

One question is what happens if you decide to change how your URLs are constructed? What if you decide to use “!” in the place of your “/” instead? The perfect solution is to use Mach-II’s BuildUrl and BuildUrlToModule functions:

<a href="#BuildUrl('hello', 'firstName=Adrian|lastName=Scott')#">Hello Adrian</a>

BuildUrl accepts an event name and a pipe-delimited string of name/value pairs to be used in order to construct your URL.

BuildUrl(eventName, [urlParameters], [urlBase])
eventName String Name of the event this URL will be built for.
urlParameters Pipe-delimited String or Struct A string following the name/value pair format or a struct of parameters where the struct keys will bec ome the names of the URL arguments.
urlBase String Used to change the base of the URL independent of the global setting.

BuildUrlToModule goes one step further and allows you to also provide the module name you wish to assign to this event.

BuildUrlToModule(moduleName, eventName, [urlParameters], [urlBase])
moduleName String Name of the module this URL will be built for. Using a value of “” defaults to the base module.
eventName String Name of the event this URL will be built for.
urlParameters Pipe-delimited String or Struct A string following the name/value pair format or a struct of parameters where the struct keys will bec ome the names of the URL arguments.
urlBase String Used to change the base of the URL independent of the global setting.

Tags: , , , , , , , ,

Leave a Reply

Spam protection by WP Captcha-Free