919 - 926 - 9847

FarCry 5.1 and the Ionic ISAPI rewrite filter for friendly URLs

The 5.1 version of the framework got a big 'ol kick in the pants (especially for a point release) with the entire friendly URL engine undergoing a rewrite (hah). I upgraded one my works in progress for Meteorsite from the 5.02 to 5.1 recently and noticed that my older friendly URLs were no longer being built by the buildlink tag, but they still worked when called with the older /go/ syntax. Hmm... time to investigate.

It turns out, you no longer need to prefix the friendly URL with a search term any longer. No more /go/ or /this/ or /something/ is required. Now, mysite.com/lets-start-this-party will work. Hey, I think it's cool at least, and the VP of marketing at my last job would have loved not having to prefix everything with a /go/.

The magic behind all of this some rather nifty REGEX string to manipulate the URL, and a new piece in the framework that verifies that friendly URLs are working (which broke my current FUs). Once you manage to pass the FU check (http://yoursite.com/pingFU returns a success), your FUs will work as desired. The REGEX and setup instructions can be found on the FarCry WIKI.

Everything was all good until... well, we're on windows, and not running Apache or the the Helicon rewrite filter. Instead, we're running the Ionic filter, and it seems the rewrite rule just doesn't work all that well based on what's in the docs. So began my quest to make that #@$#$ rewrite rule work for the Ionic filter. So, let's first run through how to install the Ionic filter.

Installing the Ionic filter

  1. If you just want to test with a single website, grab the IONIC 1.2.15. If you want to use this on multiple sites on the same machine, grab 2.0a. It really doesn't matter as the script works on both.
  2. Inside the zip, you'll find a lib folder. The two different code branches have diffrerent DLLs names and INI names.
    • 1.2.15: Doesn't matter where you put it, just not in the webroot. Put the IsapiRewrite4.dll and IsapiRewrite4.ini file in a separate folder (good to only have them in there by themselves).
    • 2.0a: Again, put it where you want, but not in the webroot (for 2 of 3 files). Put the IirfGlobal.ini and Iirf.dll in the same folder. Place a Iirf.ini in your webroot.
  3. The script I send should be used in either case for either Iirf.ini, or IsapiRewrite4.ini. Don't touch the IirfGlobal.ini, it only takes the options already in the file.
  4. Windows permissions seem to be the biggest gotcha here. The files all seem to need, at minimum, IIS_WPG and IUSER_. Mine also have Users, SYSTEM, and Administrators if it just the first two don't work for you.
  5. Open up the IIS Admin tool.
  6. Click on web service extensions, and add a new extension for "Ionic Rewriter" (doesn't matter, but I think you need to be consistant here) and choose the appropriate DLL (depending on 1.2.15, 2.0a). Be sure to check the box to set for allowed.
  7. Depending on the level you want to filter at (all sites, just one site) right click and get properties. Click on the ISAPI Filters tab and add the appropriate DLL and click apply or OK (doesn't matter).
  8. Restart the IIS admin (should restart all of the various services too).

My current rewrite script - constantly evolving


# Firstly, let's make sure that the URL is not an admin
# function. The "!" does not work here
# So it was removed. Added [L] to stop processing other
# rules for recursion issues. If you have .xxx files that
# take a URL param, add it here
RewriteCond %{HTTP_URL} (^/farcry|^/webtop|^/flex2gateway|^/flashserviReces|^/cfide|\.cfm|\.swf|\.xml)($|/)
RewriteRule ^(.*)$ $1 [L]

# Next, if it doesn't match the above, let's to see if
# there's a "?" in the string and rewrite it to be
# a "&". This is to catch cases like
# /something/?this=here. We stop processing here to
# prevent going all circular in our logic by using the "[L]".
RewriteCond %{HTTP_URL} (.*)(\?)(.*)
RewriteRule (.*)(\?)(.*) /index.cfm?furl=$1&$3 [L]

# This was junked as the first rule replaced it, but
# leaving it here just in case commented out
#RewriteCond %{HTTP_URL} (^\.index.cfm)
#RewriteRule ^(.*)$ $1

# Last, failing all else, rewrite the string to the
# normal furl sequence. Removed the checking
# for a space from the WIKI sequence as it breaks for IONIC.
RewriteRule ^([a-zA-Z0-9\/\-\%:\[\]\{\}\|\;\<\>\?\,\*\!\@\#\$\(\)\^_`~]*)$ /index.cfm?furl=$1

Be sure to follow all of the directions in that WIKI entry, in addition to what I've provided here. At this point, it works for everything that I've thrown at it. Going to /cfide, or /farcry works. Going to the normal .cfm files works, and my flash players all work. I've run into the odd issue where I've tried to reference the application.url.conjurer URL, but I've since switched to buildlink to replace calls to that variable. The other odd issue is that the first condition was having case sensitivity issues.

Related Blog Entries

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
Michael Groves's Gravatar The case sensitivity is in your last entry. Use .* instead of a-zA-Z0-9. Give me a call, I'll point you to some great examples i deved on the fpc server.
# Posted By Michael Groves | 7/4/09 9:31 PM
Matthew Williams's Gravatar Meh.. the only reason to go down this thorny path any further is in the case where we end up with a server that requires multiple websites and rules that match each site. And, those sites are only on IIS. It's just simpler at this point to not waste the time on IONIC as the Helicon filter "just works" and Apache also "just works". If we do need to revisit it, we'll get together on it in the future ;).
# Posted By Matthew Williams | 7/6/09 1:02 PM
Cheeso's Gravatar I'd be glad to help you get the rules for IIRF working for your purposes. It sounds like you're having trouble with the regex syntax, which is pretty common as regex is so baroque. The ! does not work as a regex negater - you will have to use something like (?!foo) . anyway use the IIRF forums if you need help, I'l be there.
# Posted By Cheeso | 7/14/09 12:51 PM
Mindfull's Gravatar What is this really for?? I mean, is it for re-writing all of the URLS on your site, but with one script, or does the script re-write your URLS independently based on certain variables?? Thank you so much for posting, All the best, <a href="http://mindfullseo.com/">Los Angeles Seo</a>
# Posted By Mindfull | 1/11/10 8:45 AM
Matthew Williams's Gravatar Specifically, this relates to rewriting URLs for the FarCry CMS using the Ionic filter. It differs from how apache handles rewriting enough to be problematic. The idea is, for every URL (excepting /farcry, /cfide, etc.), rewrite it to /index.cfm?furl=ojbjectid&<query string>. So, yep, it is intended for rewriting all URLs on the site.

The application stores a list of URLs that match a page objectid. If found to have a match, it supplies the objectid after furl=. The browser is really none the wiser, since all it ever sees is the friendly URL.
# Posted By Matthew Williams | 1/11/10 4:33 PM