Forum Moderators: phranque

Message Too Old, No Replies

change upper case to lower case

change url UPPERCASE to lowercase

         

fernan

8:17 am on Mar 11, 2005 (gmt 0)

10+ Year Member



using .htaccess how can i change my url

from
www.mysite.com/Regional/Europe/Ireland/

www.mysite.com/regional/europe/ireland/

and all the links in my site

many thanks

fernan

jdMorgan

9:17 pm on Mar 11, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



mod_rewrite's capability to handle this type of rewrite is very limited in an .htaccess context. In httpd.conf, you can use the OS'es tolower function or use RewriteMap, but these are not available in .htaccess.

If you have no access to httpd.conf, you can try one of these options:

  1. Use mod_speling if available on your server.
  2. Rewrite all requested URLs containing any uppercase letter(s) to a PERL or PHP script, written to modify the case and redirect to the all-lowercase URL.
  3. If neither of those approaches works, you can use 26 sequential rules to detect each uppercase letter and replace it with the lowercase equivalent. The routine needs to continue to run until no more uppercase letters are present. Obviously, this is horribly slow. Place the code as close to the beginning of your .htaccess file as possible.

 # Skip this entire section if no uppercase letters in requested URL
RewriteRule ![A-Z] - [S=28]
# Else rewrite one of each uppercase letter to lowercase
RewriteRule ^([^A]*)A(.*)$ /$1a$2
RewriteRule ^([^B]*)B(.*)$ /$1b$2
RewriteRule ^([^C]*)C(.*)$ /$1c$2
...
RewriteRule ^([^Z]*)Z(.*)$ /$1z$2
# If more uppercase letters remain, re-invoke .htaccess and start over
RewriteRule [A-Z] - [N]
# Else do a 301 redirect to the all-lowercase URL
RewriteRule (.*) http://www.example.com/$1 [R=301,L]

Jim