Forum Moderators: phranque

Message Too Old, No Replies

Rewrite URL to lowercase in .htaccess

Rewrite URL to lowercase in .htaccess

         

localghost

8:59 am on Aug 26, 2005 (gmt 0)

10+ Year Member



Hello there,

I am new to the mod_rewrite module of Apache.
Here is my issue:

My website is hosted on a Linux machine, Apache 1.3.
It is well known that the URLs of such web server are case sensitive:
[mysite.tld...]
is not the same as
[mysite.tld...]

That is the thing I am trying to avoid. I am trying to redirect all the links to be case INsensitive, so that when you type: [mysite.tld...] the Apache automatically to request/redirect to [mysite.tld...] (lowercase of all folders).

What I have tried is a .htaccess (because, the server is public and I do not have access to httpd.conf). The content of the file:

RewriteEngine on
RewriteMap lowercase int:tolower
RewriteRule ^(.+) ${lowercase:%{REQUEST_URI}}

What I get is a Error 500 and the error log says: "RewriteMap not allowed here"

My question is: Can this be done with .htaccess file with mod_rewrite directives or combination of mod_rewrite and some PHP code?

I am new to mod_rewrite, any help will be greatly appreciated :)
I have tried to search for a similar problem in this forum, but couldn't find anything.

Thank you! You rock! :)

jd01

10:19 am on Aug 26, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi localghost,

Welcome to WebmasterWorld.

The short answer is no, you can't. RewriteMap is only available in the httpd file, so you cannot easily convert to lowercase. Sorry.

The longer answer is if it is only the first letter of the URL and you do not have too many first letters, you could probably make something work, but you will need a separate rule for every letter a file starts with.

If you are set on changing them, and there are very many, an idea might be to:
1. Rewrite a couple at a time.
2. Contact those linking to the pages and ask them to change the links.
3. Wait for the changes to take effect in the SEs.
4. Change to another set of letters.

Sorry, not much help.

Justin

dcrombie

10:30 am on Aug 26, 2005 (gmt 0)



You might want to ask your host about mod_speling [httpd.apache.org]...