Apache mod_speling case insensitive URLs issue

只愿长相守 提交于 2019-12-03 11:22:05

问题


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?


回答1:


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.




回答2:


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



回答3:


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
    



回答4:


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




回答5:


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.



来源:https://stackoverflow.com/questions/3450032/apache-mod-speling-case-insensitive-urls-issue

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