Case insensitive redirect

lydia09

New Member
Messages
64
Reaction score
0
Points
0
Hi everybody,
Sorry if this is the wrong forum to put this in, first off.

I was wondering, I know there's a way to do redirects in the control panel, but is there a way to do a case-insensitive redirect?

For example, I have a directory like this:

mysite.com/Directory

That redirects to:

mysite.com/Directory/Index.php.

When I type in:
mysite.com/directory

or any other variant with the improper capitalization, I get a 404 not found error. I'd like to be able to redirect as long as the directory is right without capitalization, so if a user accidentally forgets to capitalize, it isn't a problem.

Can anyone tell me, please, is there a way to do this?

Thanks,
Lydia
Edit:
Never mind, I got it.

For future reference, it doesn't look like you can do this in the control panel, you have to do it in htaccess. Add "NC" after the "R" in your redirect directive to make "[R,NC]" and that does it.

Hope that helps someone,
Lydia
 
Last edited:

abelonger

New Member
Messages
8
Reaction score
0
Points
0
It's amazing the things you can do with htaccess. Glad you figured it out!
 

marshian

New Member
Messages
526
Reaction score
9
Points
0
For even further future reference, it's mod_rewrite they're talking about =P
Further more, NC doesn't decapitalise the string at all, it just makes the pattern case-insensitive. Perhaps it happens to work for you, but there's no reason why it should.

Adding this to your htaccess *should* work, although it doesn't appear to be on my own development environment :s
Code:
RewriteCond %{REQUEST_URI} [A-Z]
RewriteRule ^(.*)$ ${tolower:$1}
 
Top