0

I want if someone type the url like this

  1. http://sim.com/Contact
  2. http://sim.com/CONTACT

then it will be redirected to http://sim.com/contact

Hoh
  • 1,196
  • 1
  • 12
  • 30
  • possible duplicate of [.htaccess case sensitive and mod\_rewrite](http://stackoverflow.com/questions/16579652/htaccess-case-sensitive-and-mod-rewrite) – Hoh Jan 09 '14 at 08:59
  • i cannot understand please let me know how to do ? – user3172717 Jan 09 '14 at 11:23

1 Answers1

1

First add this line in <VirtualHost> section OR at the end of your httpd.conf file:

RewriteMap lc int:tolower

Then have this rule in your .htaccess file:

RewriteEngine on
RewriteRule ^(.*?[A-Z].*)$ /${lc:$1} [R=301,L]
anubhava
  • 761,203
  • 64
  • 569
  • 643
  • thanks for your answer but i dont know where this file locate http.conf and i write this line to htaccess it redirected to main website url but i want it will redirected to lower case – user3172717 Jan 09 '14 at 10:15
  • This is the only way to lowercase URIs. You need to contact a server admin to help you out for changing Apache server cofnig. – anubhava Jan 09 '14 at 10:16
  • hi anubhava server admin said they cannot change apache server because they have shared hosting please let me know is this is helpful to me RewriteCond %{REQUEST_URI} [A-Z] RewriteRule ^.+\.html$ ${lc:%{REQUEST_URI}} [NC,R=301,L] RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.(php|html) [NC] – user3172717 Jan 09 '14 at 11:16
  • See without `RewriteMap` defined in `httpd.conf` you can't use `${lc:$1}` – anubhava Jan 09 '14 at 11:17
  • but the above code is working on one of my website but that site url is differ with the current in that i was not define RewriteMap – user3172717 Jan 09 '14 at 11:20
  • In that case `RewriteMap` would have been there by default. – anubhava Jan 09 '14 at 11:22