I need to redirect all address in my website from upper case to lower case, except the last part of the URL.
For example, I want to change
www.domain.com/a/B/C/XpTo
To
www.domain.com/a/b/c/XpTo
Only the last part (XpTo) remained unchanged.
However, I can also have:
www.domain.com/A/XpTo
And I need:
www.domain.com/a/XpTo
That is, even with a small path, only the last part must remain unchanged. How can I achieve that with .htaccess, without using RewriteMap in the Apache config file?
This is what I have tried:
RewriteEngine On
RewriteCond expr "tolower(%{REQUEST_URI}) =~ /(.*)/"
RewriteRule [A-Z] %1 [R=302,L]