views:

329

answers:

4

I have created folders in my root example: http://www.zipholidays.co.uk/Cuba or http://www.zipholidays.co.uk/Florida

When I type http://www.zipholidays.co.uk/cuba (Cube in lowercase), it shows page not found.

I'm using Apache server. People are linking to pages with lowercase, uppercase, mixed case - whatever. What do I do to make the pages case insensitive?

A: 

Maybe you can replace linux for windows as the server OS.

Apache on Linux is case sensitive in the filepaths, so also in the URI's. Windows file system isn't case sensitive, so it doesn't matter there.

Gerrit
Why is this answer down voted? Am I technically incorrect, or do you just disagree with my answer?
Gerrit
I haven't downvoted you but I think you give a radical solution with a lot of costs only to solve one tiny problem.
netadictos
The URL path is case sensitive. So `/Cuba` and `/cuba` would be considered as different resources.
Gumbo
+2  A: 

If you make your pages case insensitive, you'll have some duplicate content problems as you will have two pages with the same content.

A good solution would be to do some 301 redirect on every 404 page when the equivalent in lowercase exists.

For example in your 404 default page, you put :

<?php
    $lower = strtolower($_SERVER['REQUEST_URL']);
    if (file_exists(PATH_TO_YOUR_APPLICATION . $lower) {
        header('location: ' . $lower, true, 301);
        die();
    }
?>

So when you load a 404 page, if the same url in lower cases exists, you redirect there. Otherwise you can display your own missing page content.

Damien MATHIEU
Just two? Heck, you have cuba, Cuba, CuBa, CubA, CUba, etc, etc... Far more than two pages.
Matthew Scharley
FYI, this is correct, but just turning on mod_spelling does this, and it Just Works[tm]
Matthew Scharley
+3  A: 

mod_spelling perhaps? mod_spelling

tliff
your speling of mod_speling is off ;-)
bobince
This is not a spelling issue. How to treat upper- and lowercase charachers in URL's is a long standing problem in webdevelopment.
Gerrit
Spelling issue or otherwise, `mod_spelling` **does** address what the OP was asking about, namely miscapitalised urls.
Matthew Scharley
+1  A: 

I wouldn’t make my URLs case insensitive. Instead I would follow a strict guideline for creating such URLs. I would for example only use lowercase URL paths and redirect requests with URL paths with uppercase letters to the lowercase variant.

You can even do that with mod_rewrite (requires rewrite map to internal tolower function):

RewriteCond %{tolower:%{REQUEST_URI}} .+
RewriteRule ^[^A-Z]*[A-Z] %0 [L,R=301]
Gumbo