Making Apache 2.2 on SuSE Linux Case In-Sensitive. Which is a better approach?

Posted by pingu on Server Fault See other posts from Server Fault or by pingu
Published on 2011-05-17T23:26:55Z Indexed on 2012/06/27 3:18 UTC
Read the original article Hit count: 528

Filed under:
|
|

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

© Server Fault or respective owner

Related posts about linux

Related posts about apache2