Monday, June 18, 2007

URL Rewrite FOR IIS with RegEx support and it isFREE!!!

Well, as I was learning how to do SES (Search Engine Safe) URLs with Coldfusion and IIS , I learned that CF had a built in feature that allowed you to do this. The only problem was that it still required you to have the *.cfm file in your address and your variables/values following separated by "/" rather than the default url patterns.

ie. http://mysite.com/index.cfm/myVariable/itsValue/
translates to
http://mysite.com/index.cfm?myVariable=itsValue

Honestly, this was fine for me, but I wanted to have the ability to rewrite URLs outside of Coldfusion, like Apache's mod_rewrite, which in turn would allow me to create true pretty URLS.

ie. http://mysite.com/theValue/
translates to
http://mysite.com/index.cfm?theVariable=theValue

I did some research online regarding ISAPI filters for IIS but most lacked Regular Expression Support unless you were willing to fork out some extra money for paid for versions. Then, Ray Camden introduced me to IIRF (Ionic's ISAPI Rewrite Filter), a small, cheap, easy to use, URL rewriting ISAPI filter that combines a good price (free!) with good features.

This product is amazing, not only because of price (I did mention it was free right?) but implementation is easy. Their directions are thorough and supply enough examples that you will be up and running in minutes. Thanks for the info Ray!

Click here to go to Ionic's Site

Until next time ...

2 comments:

  1. Anonymous2:28 AM

    Hi


    Can you please tell me the rewrite rule that you specified in order to achieve what you were speaking about.


    Than ks

    ReplyDelete
  2. Hey raghav,

    Sorry I took so long to respond, but the example I had is basically in the samples for IIRF. Below is an example of one of the scripts I used.

    # THE RULES
    #
    # LEVEL 1 - VIEW PROPERTY
    #
    # Level1 rules takes care of the initial view such as community or Immediate Availability
    # It basically looks for URLs going to /communities/ with two additional parameters = 1 new one

    RewriteRule ^/communities/([^/]+)/([^/]+)/$ /communities/?propertyID=$1 [L]

    ReplyDelete