URL with uppercase/lowercase letters

Soldato
Joined
4 Jan 2004
Posts
7,774
Location
Nottingham
Hi Guys

I have a bit of an issue with a site I've created. I've (foolishly?) created sub-folders for each section of my site and given them an uppercase letter at the beginning e.g:

Contact​

so the URL would look like www.website.co.uk/Contact to take me to the contacts page.

If I type www.website.co.uk/contact with a lowercase c in contact then I get a 404 error.

Is there anything I can do to auto re-direct the URL's regardless of how it's typed to the correct one?

the site is hosted on a virtual machine thats running a LAMP webserver (apache, mysql, phpmyadmin)
 
I was trying to avoid that option as it would mean editing every link on this site as I've pretty much finished it lol

Besides, from a usability POV surely it would be a good thing that people can get to the site regardless of how they type the URL's case?
 
What is the site running? Do you use your own custom HTAccess rules? Give us a bit more information.
 
Besides, from a usability POV surely it would be a good thing that people can get to the site regardless of how they type the URL's case?

Nobody will ever, ever type these URLs directly into an address bar. I'd say change them to lowercase. As you've said the site's finished and you don't want to change the links because there's a lot to change, I'll assume you've done it as flat files. You can very easily change text like this using a nice editor such as EditPlus 3, in multiple files at once.
 
just go through and change them. use find and replace on your text editor and go through one at a time. i bet it will be quicker then you think if you put some va va voom into it. how big is the site?
 
renaming the folders is really the only solution because on Unix type systems, the directories are case sensitive at the file system level.

I guess one way you could do it would be to serve the files out by php.

so your .htaccess would be like

PHP:
# Turn on URL rewriting
RewriteEngine On

# Installation directory
RewriteBase /

# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php/$0 [PT,L]

Then in your index.php you can have some basic logic to return the correct file.
 
The lesson you've probably learnt is that you should always stick with lower case. Saves lots of hassle!

As has been suggested above, use Find and Replace to edit your files - if you have a lot of files to open there are plenty of editors that can be pointed at a directory to Find & Replace on multiple files rather than opening each one individually.
 
Back
Top Bottom