Rewrite apache variables using RewriteMap
The RewriteMap directive defines an external function which can be called in the context of RewriteRule or RewriteCond directives to perform rewriting that is too complicated, or too specialized to be performed just by regular expressions. The source of this lookup can be any of the types listed in the sections below, and enumerated in the RewriteMap reference documentation.
For lowercase:
RewriteEngine On
RewriteMap lc int:tolower
RewriteRule ^ - [E=LANGUAGE:${lc:%{ENV:LANGUAGE}},E=COUNTRY:${lc:%{ENV:COUNTRY}},L]
# (Or just the "COUNTRY")
RewriteRule ^ - [E=COUNTRY:${lc:%{ENV:COUNTRY}},L]
For upper case:
RewriteEngine On
RewriteMap up int:toupper
RewriteRule ^ - [E=LANGUAGE:${up:%{ENV:LANGUAGE}},E=COUNTRY:${up:%{ENV:COUNTRY}},L]
# (Or just the "COUNTRY")
RewriteRule ^ - [E=COUNTRY:${up:%{ENV:COUNTRY}},L]