-1

I guess this is .htaccess related question rather then php.

Here is my problem, I have several URL that contain both lower and upper case characters.

If by an accident the character is mistyped, then this would cause a 404. My question is, how can I correct the mistyped character to the right case such as mysite.com/MyFolder/something.html from mysite.com/myfolder/something.html.

I guess this has to be some way of doing this using .htaccess rewrite rules, but I am not particularly a huge pro on this subject.

I have had to place this edit to my question, because I think it was misinterpreted.

So here is the problem, the above mentioned URL is somehow being corrected right within the address bar on one of my competitors website, no matter which letter case you use, as long as it is spelled correctly, the URL it self will jump to the correct case.

So if you spelled something like the following mysite.com/myfoLDer/something.html it will automatically correct the URL and give the following mysite.com/MyFolder/something.html right in the address bar of the browser on any given URL.

Please help me a little or a lot.

Thanks in advance.

AlexB
  • 2,164
  • 6
  • 27
  • 61
  • possible duplicate of [How do I make urls case insensitive in linux server](http://stackoverflow.com/questions/14814419/how-do-i-make-urls-case-insensitive-in-linux-server) – WinterMute Apr 03 '14 at 19:16
  • No it is not actually, my question is substantially different, instead of making URL case sensitive, I need to somehow correct it so that it is matched to the actual virtual directory and correct any mistyped letter to the correct case. – AlexB Apr 03 '14 at 19:24
  • Please add the contents of your `.htaccess` to the question body – Timbo_KZ Apr 03 '14 at 19:27

3 Answers3

1

Use mod_rewrite for ignoring case handling by using NC flag:

RewriteRule (.*) http://www.example.com/$1 [NC]

RewriteRule Flags - Apache HTTP Server:

Use of the [NC] flag causes the RewriteRule to be matched in a case-insensitive manner. That is, it doesn't care whether letters appear as upper-case or lower-case in the matched URI.

In the example below, any request for an image file will be proxied to your dedicated image server. The match is case-insensitive, so that .jpg and .JPG files are both acceptable, for example.

Community
  • 1
  • 1
Ilia Ross
  • 13,086
  • 11
  • 53
  • 88
0

You could try mod_speling and the CheckCaseOnly directive:

CheckCaseOnly On

assuming you've got mod_speling loaded.

Jon Lin
  • 142,182
  • 29
  • 220
  • 220
0

Looks like this question was already answered here:

.htaccess case sensitive and mod_rewrite

Use of the [NC] flag causes the RewriteRule to be matched in a case-insensitive manner. That is, it doesn't care whether letters appear as upper-case or lower-case in the matched URI.

Community
  • 1
  • 1
Timbo_KZ
  • 88
  • 7