17

I want to have case insensitive URLs using Apache's mod_speling module, but this is producing unwanted lists of "multiple options" whilst the Apache documention says

When set, this directive limits the action of the spelling correction to lower/upper case changes. Other potential corrections are not performed.

I'm testing this on an Apache 2.2.16 Unix fresh install but I'm still running into exact the same problems as submitted in 2008.

It's unexpected (and not wanted) behaviour when Apache lists a few "multiple choices" (status code 300) when the checkCaseOnly directive is on!

I have this in my httpd.conf:

CheckSpelling on
CheckCaseOnly on

First directive to use the mod_speling, second directive to limit only to case corrections

What am I doing wrong?

Darryl Hein
  • 142,451
  • 95
  • 218
  • 261
Bart
  • 171
  • 1
  • 1
  • 4
  • 1
    Did you ever solve this? I am running in to the same issue. – CJ F Mar 12 '14 at 18:08
  • Update as on 25/02/2020 - The Apache bug as mentioned by user1647075 above is still not fixed. You will still face multiple choices 300 error when using the mod_speling module. – Sathish Balan Feb 24 '20 at 22:55

5 Answers5

11

TLDR: CheckCaseOnly is broken due to a bug that has remained unfixed for over six years as of 10/2014.

I know this is an old question, but I just ran into the same issue. This update is to help others with the same issue.

The current answers to this question are incorrect, as the OP is using mod_speling correctly, but there is a bug.

https://issues.apache.org/bugzilla/show_bug.cgi?id=44221

The underlying issue is that the apache people are in disagreement over fixing this behavior because it changes the rest of the module. This has remained unfixed for something like 6 years.

user1647075
  • 141
  • 1
  • 3
  • The OP actually contributed to that same bug report at the time they posted their question here (in fact, the question is partly a word for word copy of their bugzilla post) - not sure why this was not referenced at the time? – MrWhite Mar 07 '21 at 18:38
10

To enable mod_speling (either by Location or VirtualHost) use the directive:

CheckSpelling On

If all you want is case insensitivity use:

CheckCaseOnly On

You also need to have RewriteEngine enabled:

RewriteEngine On
Nelson G.
  • 5,145
  • 4
  • 43
  • 54
fijiaaron
  • 5,015
  • 3
  • 35
  • 28
  • "You also need to have RewriteEngine enabled" - Is there any reference for this? AFAIK there has never been a dependency between mod_speling and mod_rewrite and simply enabling the rewrite engine doesn't really make sense IMO? (Although, as noted in the other answers - and the question - the enabling of mod_speling is not the issue here.) – MrWhite Sep 15 '19 at 14:51
8

On Ubuntu 12.04 LTS using Apache 2.2, I did the following:

  1. Create speling.conf in ${APACHE}/mods-available to provide the config options.

    <IfModule mod_speling.c>
        CheckSpelling On
        CheckCaseOnly On
    </IfModule>
    
  2. Link speling.conf and speling.load into the enabled modules directory ${APACHE}/mods-enabled:

    # cd ../mods-enabled
    # ln -s ../mods-available/speling.conf speling.conf
    # ln -s ../mods-available/speling.load speling.load
    
  3. Restart the server.

    # service restart apache2
    
icedwater
  • 4,701
  • 3
  • 35
  • 50
1

After reading user1647075's answer about this being a known Apache bug that's unlikely to be fixed, I decided my best option was to hide the "multiple options" page from the user by updating my Apache config to show the 404 error page for 300 status codes:

ErrorDocument 300 /404.htm

Of course, you can also create a custom error page instead of reusing the 404 error page.

Hope this workaround helps.

Sandra
  • 13
  • 4
0

Do you really want case insensitive URL?
Why not just force lowercase urls, like this?

RewriteEngine On
RewriteMap lc int:tolower
RewriteRule (.*) ${lc:$1} [R]

Have a look at http://www.issociate.de/board/post/265865/make_URL

Bracke
  • 122
  • 3
  • 11
  • 3
    ACtually this is all sorts of wrong now that I've tried it. Even the rewriteRule is actually incorrect here... – Shackrock Apr 26 '13 at 00:46
  • Ironically, this is the same [example as posted in the Apache docs](https://httpd.apache.org/docs/2.4/rewrite/rewritemap.html#int), although there is a warning at the top of that page that states, "Note that many of these examples won't work unchanged...". And that is certainly the case here - it is incomplete. (Or "wrong", depending on how you look at it.) Without some condition to check that the requested URL contains uppercase letters then this directive will result in a redirect loop. – MrWhite Mar 09 '21 at 11:35
  • It should also be noted that `RewriteMap` directives can only be defined in the server config (_server_ or _virtualhost_ context), ie. _not_ `.htaccess`. – MrWhite Mar 09 '21 at 11:38