We 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.)
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:
/pcefor/PCEFor/PceFetc 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]