Apache mod_speling case insensitive URLs issue

前端 未结 5 661
攒了一身酷
攒了一身酷 2021-02-05 10:24

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

相关标签:
5条回答
  • 2021-02-05 10:55

    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
    
    0 讨论(0)
  • 2021-02-05 11:02

    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.

    0 讨论(0)
  • 2021-02-05 11:04

    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
      
    0 讨论(0)
  • 2021-02-05 11:13

    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.

    0 讨论(0)
  • 2021-02-05 11:14

    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

    0 讨论(0)
提交回复
热议问题