Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Problem:

   http://<server>/home/APPLE.html  
    http://<server>/hoME/APPLE.html
    http://<server>/HOME/aPPLE.html
    http://<server>/hoME/aPPLE.html

All the above should pick this

    http://<server>/home/apple.html

I implemented 2 solutions and both are working fine. Not sure which one is better(performance). Please Suggest..Also Directive - CheckCaseOnly on never worked

Option 1:

a)Enable:mod_speling In /etc/sysconfig/apache2 - APACHE_MODULES="rewrite speling apparmor......"

b) Add directive - CheckSpelling on (Either in .htaccess or add in httpd.conf) In httpd.conf

<Directory srv/www/htdcos/home>
Order allow,deny
CheckSpelling on
Allow from all
</Directory>

or

In .htaccess inside /srv/www/htdcos/home(your content folder)

 CheckSpelling on

Option 2:

a) Enable: mod_rewrite

b) Write the rule vhost(you can not write RewriteMap in directory. check apache docs )

<VirtualHost _default_:80>

<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteMap  lc int:tolower
RewriteCond %{REQUEST_URI} [A-Z]
RewriteRule (.*) ${lc:$1} [R=301,L]
</IfModule>

</VirtualHost>

<VirtualHost _default_:80>

<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteMap  lc int:tolower
RewriteCond %{REQUEST_URI} [A-Z]
RewriteRule (.*) ${lc:$1} [R=301,L]
</IfModule>

</VirtualHost>

This changes the entire request uri into lowercase. I want this to happen for specific folder, but RewriteMap doesn't work in .htaccess. I am novice in regex and Rewrite. I need a RewriteCond which checks only /css//. can any body help

share|improve this question

migrated from stackoverflow.com May 19 '11 at 14:15

This question came from our site for professional and enthusiast programmers.

1  
Since you say you only want this to happen for content under your /css/ directory, it's probably worth mentioning that the most performant solution is to avoid the problem entirely, and fix the code to only refer to stylesheets by their lower-case filenames. –  nickgrim Nov 1 '12 at 8:11
    
URLs are case sensitive, period. If you're running into this "problem", it's your development process you need to fix. –  Michael Hampton Jan 8 '13 at 1:22
add comment

1 Answer

The mod_rewrite solution doesn't make Apache case insensitive. It just makes sure that if the request is uppercase or mixed-case it will match resources which are lowercase. It doesn't address the situation in which the resource you want to serve is uppercase or mixed-case and the request doesn't properly match. It is not possible to make Apache case insensitive using mod_rewrite. (reference)

If you are sure that all the resources you ever serve will be lower case than this may meet your needs, but it is not case insensitive. Another potential issue is that the rewrite rule doesn't actually validate that the resource exists so, you may end up returning a 301 permanent redirect to a resource which doesn't exist. The impact to you may be minimal depending on how many case errors you get. The server will receive the second bad request and return a 404 which means increased load. No matter the impact to you returning a permanent redirect with a url that doesn't exist is bad form.

The mod_speling solution is actually case insensitive and will not return a redirect for a non-existent resource. There is some overhead since a directory scan needs to be performed by mod_speling to validate url against the target. If you are only concerned about case than use the CheckCaseOnly on directive to limit the checks performed by the module and thus the overhead.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.