URL Rewriting

Making URLs prettier using URL rewriting.

URL rewriting is a completely optional feature of Wheels, and all it does is get rid of the index.cfm part of the URL.

For example, with URL rewriting off, a URL in your application cold look like this:

http://localhost/index.cfm/blog/new

After turning on URL rewriting it would look like this:

http://localhost/blog/new

Combine this with the routing functionality of Wheels, and you get the capablility of creating some really human-friendly (easier to remember, say over the phone, etc.) and search engine friendly URLs (easier to crawl, higher PageRank, etc.).

Unfortunately, if you're running your Wheels site in a subfolder of another site, you will not be able to turn on URL rewriting, so we recommend running the Wheels site as a stand-alone site whenever possible. If you've met this one requirement and want the shortest and prettiest URLs possible, then just follow the instructions below.

Instructions for Apache

  1. Check that the Apache rewrite_module has been loaded by ensuring there is no pound sign before the line that says LoadModule rewrite_module modules/mod_rewrite.so in the httpd.conf file.
  2. Make sure that Apache has permission to load the rewrite rules from the .htaccess file in the web root. This is done by setting AllowOverride to All under the Directory section corresponding to the website you plan on using Wheels on (still inside the httpd.conf file).
  3. Uncomment the rewrite rules inside the .htaccess file itself located in the web root. (Remove the pound signs.) For some Apache setups, this is actually the only thing that you need to do.

Instructions for IIS

Unfortunately, there is no built-in URL rewriting mechanism in IIS, so getting Wheels working with pretty URLs is a little more complicated than with Apache. Here's what you do:

  1. Download Ionic's ISAPI Rewrite Filter.
  2. Unzip the file and put the .dll file in the root of your website. (It needs to be in the same folder as the IsapiRewrite4.ini file.)
  3. To enable the rewrite filter in IIS, click on Properties for your website, then go to the ISAPI Filters tab and click the Add... button.
  4. Type in anything you want as the Filter Name and point the Executable to the IsapiRewrite4.dll file.

Now restart your web server and enjoy those fancy new URLs. :)