uppercase first segment of url using HTACCESS

ellandrd
ellandrd used Ask the Experts™
on
I need to change the first segment of my URL to uppercase but it isn't working.  All other URL segments should remain lowercase.

example:

http://www.domain.com/en/ should become http://www.domain.com/EN/
http://www.domain.com/en/home/ should become http://www.domain.com/EN/home/

My htaccess file is below:
RewriteEngine on
RewriteBase /

# Force the www
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] 

RewriteMap  uc int:toupper
RewriteRule ^http://www.%{HTTP_HOST}/(.*)/$ http://www.%{HTTP_HOST}/${uc:$1}/ [R=301,L]

# Add a trailing slash to paths without an extension
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule ^(.*)$ $1/ [L,R=301]

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
I think you will find that the client side browser defaults to lower case

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial