Solved

mod_rewrite and mod_speling not working together

Posted on 2006-07-06
1
1,296 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

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…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

863 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

22 Experts available now in Live!

Get 1:1 Help Now