Wednesday, July 28, 2010

CaSe Matters

abc Budding young web designers and developers usually learn this pretty quick, when creating a page on Windows and not using the same case as the files and folders they are linking to. They often will use lowercase in all the URLs, regardless of the case of the actual file and folder names. And this will work fine when viewed on their Windows machine. But as soon as they upload it to a server that is running something else, like Linux, it stops working. Their page is full of broken images and dead links, because they used something like mypicture.jpg in place of the actual file name of MyPicture.jpg and about.html in place of the actual file name of About.html.

Or they upload an Index.html and wonder why when they visit their site they still see the default index.html page provided by their web host and why when they check on the server there are now two index files and not one.

For the domain name part of the URL it doesn't matter. That part is not case sensitive. is the same as is the same as

For the rest of the URL it could matter, depending on what operating system is being run on the server that is hosting the site.


windows-logo_c If the server is running Windows, case doesn't matter. The reason for this is because you can only have a single file or folder of a particular name in a folder, regardless of the case used in that file or folder name.

index.html is the same as Index.html is the same as INDEX.html

All three will lead to the same page.

In Windows, adding a file or folder of the same name with a different case to a folder, overwrites the original. Only one can exist.


linux-penguin-full1_2If the server is running Linux, case matters, as you can have multiple files and folders of the same name within a folder, each having a different case.

index.html is not the same as Index.html and not the same as INDEX.html

In Linux adding a file or folder of the same name with a different case to a folder, does not overwrite the original. Linux will allow all three to exist in a folder, and each are considered different. If you change the case of a file or folder in the URL path and the server is running Linux, and that variation does not actually exist on the server, it will result in a 404.

And if you upload a file of the same name but a different case, it will not overwrite the original. You will have both on the server, and lowercase is the default index file. This is the reason why the place holder index.html supplied by your web host is still seen, even though you have uploaded your Index.html file, and why you see two index files when you view it in your FTP client.


It is always best to assume the server runs Linux when creating links to pages on the web and when typing URLs into the addressbar of your browser. It is the only way to ensure that if case matters, that you are using the correct URL.

It is also best to use all lowercase in the folder and file names of your website when creating the files and folders, regardless of what operating system you are using locally. Always assume the site will be run on a server that is case sensitive. That way there is a set standard of practice you follow that leaves less room for error.

Step 1, before you begin coding, should always be to fix all your file and folder names so you won't have to worry about it later.

blog comments powered by Disqus