Solved

mod_rewrite and mod_speling not working together

Posted on 2006-07-06
1
1,282 Views
Last Modified: 2011-03-03
I have a site where mod_rewrite is needed for a custom php framework.   The site in question is being transfered from a windows server using ASP to a linux server and will be converted to php.  On the windows server the files could called with case insensitivity.  I'm trying to duplicate this because a lot of links on the site don't match to the exact case of some of the folders or filenames.  (we didn't build the site, we're just tranfering it, and I don't know why the original developer did that.)

I enabled mod_speling but if mod_rewrite is on with our rules, it doesn't work.  If I take out our mod_rewrite rules, then mod_speling works as it's supposed to.  I understand why this happens.  Our rewrite rules have conditions that state that if the REQUEST_FILENAME is not a file or directory then execute the rule.  

I don't know if it's possible, but can mod_speling and mod_rewrite play nice and work together?

Here's the information in our .htaccess file for mod_speling and mod_rewrite.

<IfModule mod_speling.c>
    CheckSpelling On
</IfModule>

<IfModule mod_rewrite.c>
    RewriteEngine On
         
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f    
    RewriteRule ^(control)$ admin.php?use=yes [L,NC]
   
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f    
    RewriteRule ^(control/)(.*)$ admin.php?use=yes&url=$2 [L]
   
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ frontend.php?use=yes&url=$1 [L]    
</IfModule>

Thank you.
0
Comment
Question by:purfus
1 Comment
 
LVL 51

Accepted Solution

by:
ahoffmann earned 500 total points
ID: 17057004
I guess mod_spelling is a bad idea for something like you have: "a lot of links on the site don't match to the exact case of some of the folders or filenames"
This sounds like you may have files like:
  Foo.baR
  fOO.Bar
  foo.bar
and so on ...
in that case mod_spelling gets confused too.

I'd clean up your filenames, for example use only lower case.
First search for "duplicates" as I described above, and make a decision how to rename them.
Then convert all filenames to lower case:
   find . -type f -name \*.xxx -exec perl -e '$f=$ARGV[0];rename$f,lc($f);' {} \;

then you cann use a simple rewrite rule:

RewriteMap lc int:tolower
RewriteRule ^/(.*) ${lc:$1}
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now