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 http://vowe.net/images/googlead.php where I should have linked to http://vowe.net/images/googleads.php. 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 >

Comments

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

I have not tested Apache 2, though.

Steffen Uhlig, 2004-02-08 05:31

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".

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 18:54

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 ;-)

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

Justin Freeman, 2004-02-08 20:02

Post a comment











Shall I remember this for you?




Use your full name and a working email address. Unless you want your comment to be removed. No kidding.



Ceci n'est pas un blog

vowe.net is a personal website published by Volker Weber a.k.a. vowe. I am an author, consultant and systems architect based in Darmstadt, Germany.

rss Click here to subscribe

Hello

About me
Contact
Publications
Certificates
Frequently asked questions
Join the network

Poll

Which BlackBerry could be your next one?

Getting poll results. Please wait...

Local time is 08:31

visitors.gif
147 visitors online

News

Other sources of news, imported into my own format to make them more accessible:

Heise Online
Schlagzeilen
Weather
Blog roll

Archives

As most of my articles roll off the front page rather quickly, I am making an archive of previous posts available here. You can also use the handy search box at the top of the page if you are looking for something particular.

Last 30 days
More archives

Got the T-shirt?

Got the T-shirt?

Systems Architecture

This site runs on an Apache web server on top of the Linux operating system. The content is managed with MovableType 2.661 which is implemented in Perl. Last but not least the HTML code your browser sees is put together with PHP.

© 1992-2008 Volker Weber.
All Rights Reserved.

Impressum