Cool Apache feature

by Volker Weber

There is hardly a day where I don't learn something I did not know the day before. Today it was mod_speling which automagically repaired a broken link on my site. I was referring to where I should have linked to Still you could get to this page, as you can try yourself. So, how does that work?

Requests to documents sometimes cannot be served by the core apache server because the request was misspelled or miscapitalized. This module addresses this problem by trying to find a matching document, even after all other modules gave up. It does its work by comparing each document name in the requested directory against the requested document name without regard to case, and allowing up to one misspelling (character insertion / omission / transposition or wrong character)

More >


At least in Apache 1.3, mod_speling seems not to work in conjunction with MultiViews: If you have page.html.en and, all of page, page.html, page.html.en and will work. But mod_speling will only correct the spelling of the full URI, not those enabled by MultiViews. So, pege.html.en and are found, but pege.html and pege not.

I have not tested Apache 2, though.

Steffen Uhlig, 2004-02-08

Which is exactly as specified by the documentation. You have to keep in mind that you are talking about two different modules here. First, the multiview module tries to find a match for "pege.html" and "pege". Because it doesn't find a match for them, the request is passed on to mod_speling. As stated in the docs, mod_speling will only correct one letter errors. In your scenario, it would have to correct four, the typo as well as the missing extension for mod_speling only works on real file names as given back by a directory listing. Just imagine what would happen if mod_speling instead of just searching a directory would pass each likely prospect to the URI parser again. It might well be able to correct most if not all typos and omissions but at the price of a real slow website.
For your scenario to make mod_speling also correct requests for "pege.html" automagically, you would have to add another document called "page.html" that contains the content in your default language of choice. Still, there's no way to automagically fix requests for "pege".

Stefan Rubner, 2004-02-08

While I do accept the technical reason, I would rather prefer a slow response over a 404. Asking mod_speling is only needed in case of a typo and shouldn't affect the response time of correct requests.

I solved pege.html by symlinking page.html to page.html.en (with English being the default language). But I don't know a solution for "pege" either.

Steffen Uhlig, 2004-02-08

There isn't one - at least there's none that I know of. The major problem here is, that you would have make mod_speling to not only check for typos and omissions. In addition, it would have to check for all valid extensions as given in the Apache configuration, too. While I believe this could be done by hacking the code of mod_speling, I for one wouldn't do it. I'm not into teaching users that they are allowed to be sloppy ;-)

Stefan Rubner, 2004-02-08

Apache rocks! It's not hard to see why its the leading Web Server on the Internet.

Justin Freeman, 2004-02-08

Old archive pages

I explain difficult concepts in simple ways. For free, and for money. Clue procurement and bullshit detection.


Paypal vowe