Contribute  :  Calendar  :  Advanced Search  :  Site Statistics  :  Directory  :  Web Resources  :  Polls  
    Nat's Geeklog Just another brick in the Geeklog wall    
 Welcome to Nat's Geeklog
 Friday, September 03 2010 @ 12:13 PM CDT

Apache: Convert uppercase to lowercase

   
Computer Tech StuffWe had a requirement from a client whose windows website we were migrating to UNIX that the new site be able to handle mixed case tickers, ie, /pwc, /Pwc, /PWC, /pwC, etc. Using mod_rewrite, it was doable:
    # Take any mixed or uppercase ticker and set to lower
    RewriteMap    lowercase    int:tolower
    RewriteRule ^(/[A-Z]...?)$ ${lowercase:$1} [R,L]
    RewriteRule ^(/.[A-Z]..?)$ ${lowercase:$1} [R,L]
    RewriteRule ^(/..[A-Z].?)$ ${lowercase:$1} [R,L]
    RewriteRule ^(/...[A-Z])$ ${lowercase:$1} [R,L]
This case conversion will be true for any 3 or 4 char URI with an uppercase letter. (It would probably be better to replace the "." above with [a-zA-Z], as it's likely intended for only chars to replace. Above will transform /a/BB as well, which is probably not desired.)
 

What's Related

Story Options

Apache: Convert uppercase to lowercase | 1 comments | Create New Account
The following comments are owned by whomever posted them. This site is not responsible for what they say.
Apache: Convert uppercase to lowercase
Authored by: nat on Wednesday, May 05 2010 @ 10:45 AM CDT
Note that this gets easier if the target is a different path, ie: redirect /pcef or /PCEF or /PceF etc to /some/other/page/pcef. To do so, simply use mod_rewrite with the NC option:

RewriteRule ^/pcef /some/other/page/pcef [NC,R,L]

 Copyright © 2010 Nat's Geeklog
 All trademarks and copyrights on this page are owned by their respective owners.
Powered By Geeklog 
Created this page in 0.04 seconds