How To Use Search Engine Safe Urls With Mach-II
By jonkarna
Search Engine Safe (SES) urls are increasing in demand, especially by SEO departments across the board. They look better and supposedly increase search engine optimization. Since my company upgraded to version 1.5 of Mach-II, we were able to use their built in SES url functionality.
By doing this, we are transforming our urls from http://www.test.com/index.cfm?event=blog&category=seo to http://www.test.com/index.cfm/event/blog/category/seo
Here is the properties that need to be specified in the mach-ii.xml file. I originally omitted the urlBase property because I wanted it to specify relative urls (ie. index.cfm/event/blog), which it did. This worked because I specified the base url in the head tag of the page. However, I ran into a problem when I execute a redirect command in the mach-ii file. The redirect tag would just attach the relative url onto the existing url (ie. index.cfm/event/blog/index.cfm/event/blog). To avoid this, I had to either not use redirects or specify a urlBase. I decided to specify a urlBase because I love using redirects to avoid having multiple submissions of forms and better form submission pages.
I don't like having to specify urlBase because I need to change it every time I commit my code to be updated on the live server. If I ever forget, someones live site could be building urls that reference my local development environment.
<property name="urlBase" value="http://www.test.com" /> <property name="urlDelimiters" value="/|/|/" /> <property name="urlParseSES" value="true" />
While programming, instead of hardcoding urls on my own, I use mach-ii's built in BuildUrl function. If I don't specify the properties in the mach-ii.xml file, it will build my url's with a typical query string. However, if I specify the properties above, it will build them the way requested.
The first parameter specified in the BuildUrl function is the requested event. It is followed by an optional parameter for specifying variables that will show up in the url. It wants these variables specified in a piped format"variableName1=variableValue1|variableName2=variableValue2|variableName3=variableValue3" . There is one more optional parameter for specifying a different urlBase. In my experiences, this helps when you want a certain url to be built on a secure url (ie.https://www.test.com). I like to specify another propery names secureUrlBase so that if I want to specify a secure url, I would just insert a getProperty("secureUrlBase") in that last parameter slot in the BuildUrl function.
#BuildUrl("blog", "entryId=99|categoryId=45")#Comments
No comments yet.