Many servers have the option to distinguish file names based on the case of the letters that make up the file name. Web Hosting Hub servers are Linux-based and use case sensitivity on all hosting servers. The following article gives a quick summary of how this can affect your file names and advice on how to avoid the issue using best practices when developing your website.
File Names and Case Sensitivity
One of the most puzzling things about case sensitive issues for files names is that it will not always display an error explicitly describing the problem Additionally, it will list the file, but unless you happen to NOTICE that the letters have a different case, you may miss it entirely. Here's an example:
In the first name, you can see that the "F", "N" and "A" are capitalized, but the second name is ALL in lower case. If these two files were in the same folder, they would be considered two DIFFERENT files due to the difference in case.
File extensions are part of the file name and therefore they are also affected by case sensitivity. Here are some examples of file extensions:
This is different from:
The files above show the HTML extension displaying how it can be set with different case.
Image extensions should also match in spelling:
Is Not the same as:
Although the extensions BOTH indicate a JPEG file, the JPG extension is still spelled differently from the other JPEG, so these file names would be handled as two different file names.
Best practice for Linux file naming
If you are working with your files in File Manager, an FTP client like FileZilla, or the command line (on VPS/Dedicated servers) we recommend following the best practices for file naming. See the below:
- Name all your files lower case.
- Instead of using a space, use an ( _ ) or a ( - )
- Use consistent file types. Use jpg or jpg. Don't use both.
- Only alphanumeric characters, periods, underscores and hyphens and don't use symbols like “%”, “$”, and so forth.
- Do not use very long file names. Advise that the use of very long file names can cause issues with the file.
Creating file naming standards
You do not have to use the Linux best practices - that is completely up to you. However, to avoid the issues that you can see with case sensitivity, it is important that you establish a standard for the naming of your files. This becomes very important if you are working with more than one person. Different people may have different ideas on how to name your files. Simply establish your file name standards before the project starts and ensure that people know and are aware of the standards. This will help to minimize file naming issues and prevent your from having to track down possible issues that could easily have been avoided by simply naming the files in uniform way.