Mod_rewrite - change url

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.

+3
source share
3 answers

mod_rewrite has some internal functions that you can use to match. One is toupper , which converts letters to uppercase:

 RewriteMap uppercase int:toupper RewriteRule [az] %{uppercase:%{REQUEST_URI}} [L,R=301] 
+3
source

I was looking to change case only identifier. This trick did:

 RewriteRule ^id(.*)$ /ID$1 [QSA,R,L] 
+2
source
 RewriteMap uppercase int:toupper RewriteRule ^/(^/)*$ /${uppercase:$1} [L] RewriteRule ^/([^/]*)/(.*)$ /${uppercase:$1}/$2 [L] 

(syntax not checked)

+1
source

All Articles