My favorites | Sign in
Project Logo
                
Search
for

NOTE: This wiki contains "bleeding edge" documentation, which may reflect a future version of Wheels. Entries in the wiki may also be incomplete and unedited. Please visit cfwheels.org/docs for the "official" documentation.

Introduction

Handling Requests With Controllers

Database Interaction Through Models

Displaying Views to Users

Sample Applications

Working With Wheels

Contributing to Wheels

The Wheels API

Updated Apr 16, 2009 by per.djurner
Labels: chapter, 0.9.1
URLRewriting  
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 could 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 powered site in a sub folder of another site you will not be able to turn on URL rewriting (at least not without making some custom changes to your rewrite rules), 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 signs 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).

That should be it, in fact, on some Apache setups you don't have to do anything at all. Apache will pick up and use the rewrite rules specified in the .htaccess file on server start-up.

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" from http://cheeso.members.winisp.net/IIRF.aspx.
  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. :)


Sign in to add a comment
Hosted by Google Code