Convert to lowercase in a mod_rewrite rule
Solution 1:
First, put the following line in the <VirtualHost>
section of your .conf file.
(For me that lives at /etc/httpd/vhosts.d/00foo.conf
.)
RewriteMap lc int:tolower
You can replace lc
with any name you want.
Then restart apache, which you can do with sudo service httpd restart
.
Finally, add this in your .htaccess file:
RewriteRule ^/(.*)$ /${lc:$1}
Solution 2:
RewriteMap tolower int:tolower
RewriteRule ^([^/]+)/?$ somedir/${tolower:$1}
Solution 3:
I would make it a 301 redirect, NOT a URL rewrite, for SEO purposes:
RewriteMap tolower int:tolower
RewriteRule ^([^/]+)/?$ somedir/${tolower:$1} [R=301,L]