Is there an easy way to change the case of any URL using mod_rewrite?
I thought it was pretty trivial ... apparently not.
Examples:
http://example.com/ID at http://example.com/ID
http://example.com/ID/123 at http://example.com/ID/123
etc.
mod_rewrite has some internal functions that you can use to match. One is toupper , which converts letters to uppercase:
toupper
RewriteMap uppercase int:toupper RewriteRule [az] %{uppercase:%{REQUEST_URI}} [L,R=301]
I was looking to change case only identifier. This trick did:
RewriteRule ^id(.*)$ /ID$1 [QSA,R,L]
RewriteMap uppercase int:toupper RewriteRule ^/(^/)*$ /${uppercase:$1} [L] RewriteRule ^/([^/]*)/(.*)$ /${uppercase:$1}/$2 [L]
(syntax not checked)