6.2. URL Spell Checking

With the power of mod_rewrite at your side, there's very little in the way of malformed or changed URLs that you can't handle, but what about spelling mistakes? Sure, you could come up with a huge list of possible misspellings for each of the files in your website, and write about a thousand RewriteRules, but it's not necessary. To alleviate you from the burden of "simple" spellchecking, Apache comes with the mod_speling module (and yes, it really is spelled with only one "l"). With mod_speling, you can offload the task of handling URL spelling mistakes to Apache, which will automatically do its best to determine what file the user had intended to load.

To use mod_speling, start by first checking to see if it is already available to Apache as a statically built module:

/path/to/httpd –l

If you don't see mod_speling.c in the list, check the Apache modules directory for mod_speling.so:

ls /path/to/apache/modules

If you don't find either the static library or the dynamic module, you'll need to build them yourself. As before, you can choose between statically building the module into Apache itself or building it as a dynamic module.

To build the static version, change your configure command to include mod_speling, as follows:

./configure \
--enable-speling \
# ...and any other configure settings you use

If you prefer to use the dynamic module instead, just add =shared to the mod_speling line:

./configure \ --enable-speling=shared \ # ...and any other configure ...

Get Professional LAMP: Linux®, Apache, MySQL®, and PHP5 Web Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.