URL Rewriting (Part 2)

I’ve written some very basic URL rewriting scripts in the past.  With only a few URL parameters this is pretty simple to accomplish with a few lines of code.

For example, I had written a basic CMS where URLs followed a specific pattern using .htaccess scripting.  The rewrite engine would be able to convert this into something Apache can read.

  • The URL bar would read as follows:
    • http://www.domain.com/category-x/article-y
  • The web server would read this as:
    • http://www.domain.com?category=category-x&article=article-y

This is fine enough for basic URL patterns, but what happens when the URL tree is a little more complicated?  Starting in Joomla! version 1.5, they included a build in router that can be created on a component level.

Used Boats Ahoy! was created before this was available, so I continued to use the module JoomSEF from part one of this article.  Fortunately the scripting required for JoomSEF to work properly with a component followed a number of the rules the built in 1.5 router uses.  Unfortunately, JoomSEF only required instructions to generate the URLs and not to be able to return the URL to a form the web server understands, which is much more difficult.   Also, moving away from the original method meant a number of the URLs would no longer be valid which requires an extra layer of error handling.

WordPress Themes