Solved

mod_rewrite and mod_speling not working together

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

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…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

831 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