Apache mod_speling case insensitive URLs issue

爱⌒轻易说出口 提交于 2019-12-03 01:46:06

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.

fijiaaron

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

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
    

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

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!