|
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 no URL rewriting, 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 (easier to crawl, higher PageRank, etc.) URLs. Once you have uncommented the rewrite rules (found in either .htaccess, web.config or IsapiRewrite4.ini), Wheels will try and determine if your web server is capable of rewriting URLs and turn it on for you automatically. Depending on what web server you have and what folder you run Wheels from, you may need to tweak things a little though. Follow the instructions below for details on how to set up your web server and customize the rewrite rules when necessary. Instructions for ApacheOn most Apache setups, you don't have to do anything at all to get URL rewriting to work. Just uncomment the rewrite rules in the .htaccess file and Apache will pick up and use them automatically on server start-up. There are some exceptions though... If you have installed Apache yourself you may need to turn on the rewrite module and/or change the security settings before URL rewriting will work:
If you have an older version of Apache and you're trying to run your Wheels site in a sub folder of an existing site you may need to hard code the name of this folder in your rewrite rules.
Instructions for IIS 7Similar to Apache, IIS 7 will pick up the rewrite rules from a file located in the Wheels installation. In the case of IIS 7, the rules are picked up from the web.config file. (Don't forget to uncomment the XML block containing the rewrite rules in that file first.) This requires that the URL Rewrite Module is installed. It's an IIS extension from Microsoft that you can download for free. Instructions for IIS 6Unfortunately, there is no built-in URL rewriting mechanism in IIS 6, so getting Wheels working with pretty URLs is a little more complicated than with Apache and IIS 7 (which often comes with the official "URL Rewrite Module" installed by default). Here's what you need to do:
Deleting Unnecessary FilesThe sole purpose of the .htaccess (for Apache), web.config (for IIS 7), and IsapiRewrite4.ini (for IIS 6) files is to make it possible to use URL rewriting. If you don't plan on using URL rewriting at all, you can safely delete these files. Also, if you're using URL rewriting on Apache, you can delete the IIS specific files and vice versa. Don't Forget to RestartIf you need to make changes to get URL rewriting to work, it's important to remember to always restart the web server and the ColdFusion server to make sure the changes are picked up by Wheels. If you don't have access to restart services on your server, you can issue a reload=true request. It's often enough. |
Sign in to add a comment