Support

Admin Tools

#22882 File name case sensitivity

Posted in ‘Admin Tools for Joomla! 4 & 5’
This is a public ticket

Everybody will be able to see its contents. Do not include usernames, passwords or any other sensitive information.

Environment Information

Joomla! version
n/a
PHP version
n/a
Admin Tools version
n/a

Latest post by nicholas on Tuesday, 30 June 2015 17:09 CDT

helix2000
I just moved my joomla site from an iis server to an Apache VPS. I noticed that some of my images were not showing up and some of my links to pdf files were broken due to the case of the filename.

Ex. IMAGE.jpg (this is the name of the image on my server) and image.jpg (this is the way I typed the image name).

I worked with my host to enable mod_speling and set up an .htaccess file with ONLY the following:


##### RewriteEngine enabled - BEGIN
RewriteEngine On
##### RewriteEngine enabled - END

<IfModule mod_speling.c>
CheckSpelling On
CheckCaseOnly On
</IfModule>



and the images and pdf files load perfectly even though the case does not match. However, when I add this code to the htaccess file created by the htaccess maker, everything goes back to being case sensitive. Can you help me figure out what I need to add/remove from the htaccess maker file for the case insensitivity to work?

I wasn't sure if I should upload my htaccess file to this ticket or copy it to the ticket, but I can if needed.

Thank you!

dlb
That's pretty cool, I had no idea that module existed. But... (You knew that was coming, right?) From the Apache online documentation:
This directive enables or disables the spelling module. When enabled, keep in mind that:
  • the directory scan which is necessary for the spelling correction will have an impact on the server's performance when many spelling corrections have to be performed at the same time.
  • the document trees should not contain sensitive files which could be matched inadvertently by a spelling "correction".
  • the module is unable to correct misspelled user names (as in http://my.host/~apahce/), just file names or directory names.
  • spelling corrections apply strictly to existing files, so a request for the <Location /status> may get incorrectly treated as the negotiated file "/stats.html".
mod_speling should not be enabled in DAV enabled directories, because it will try to "spell fix" newly created resource names against existing filenames, e.g., when trying to upload a new document doc43.html it might redirect to an existing document doc34.html, which is not what was intended.
Basically it will fix your case problem at the expense of slowing down your site forever. Case sensitivity is a real pain when you first start out with Linux, but it becomes second nature after a while. My recommendation is to fix the case errors and don't use the module.

If you choose to use the module, note that there are two fields for adding code to the .htaccess file, one for the top and one for the bottom of the file. Sometimes it does make a difference which one you use. Whichever one you tried, try the other one. You don't want the RewriteEngine ON line in the added code, .htaccess Maker adds that one itself.


Dale L. Brackin
Support Specialist


us.gifEnglish: native


Please keep in mind my timezone and cultural differences when reading my replies. Thank you!


????
My time zone is EST (UTC -5) (click here to see my current time in Philadelphia, PA)

helix2000
Hi Dale!

I agree about fixing the case and will do so moving forward, however, I have over 700 product pages and can't go through every one to check all links and images. Eventually I will correct everything but for now I need to find a solution.

I removed all the code and added each section back one at a time to test and I have figure out that this is preventing the case from changing:

##### Joomla! core SEF Section -- BEGIN
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{REQUEST_URI} !^/index\.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L]
##### Joomla! core SEF Section -- END


Any ideas why this would be causing the issue?

Also, can you tell me where in the htaccess maker in joomla I can disable this feature?

nicholas
Akeeba Staff
Manager
Dear Heather,

Your problem comes from the way the different operating systems of the servers you chose to host your sites work. Your question has nothing to do with our software. Per our support policy we can only provide support for our software products, not the server they are running in (which of course includes your server's operating system).

I understand your frustration with having to change the URLs to several products. However there is NOTHING you can do at the .htaccess level to avoid it. Quite simply, it boils down to how each operating system deals with filenames in the file system used by the server. On Windows the file names ABC.txt, Abc.txt, abc.txt and ABC.TXT refer to the same file because the NTFS and FAT/FAT32 filesystems are case-insensitive. On Linux servers the same file names refer to four different files because the underlying filesystem (usually: ext4) is case-sensitive.

Pro tip: This is the very reason everyone is using lowercase filenames on the web. They are guaranteed to always work, no matter the server technology. Referencing a file with a different cased filename than the one stored on disk is bound to land you in hot water, which is exactly what happened.

Again, please let me state in no uncertain terms that your problem has to do with the operating system, NOT .htaccess. What you are trying to do is impossible at the .htaccess level. Even if it was possible it would be a suicide as far as performance is concerned. The filename IMAGE.jpg consists of 8 characters which can be represented in either lower or uppercase. According to what you've learned in Statistics 101 this results in a number of possible permutations expressed by the quotient of factorials 8! / (6 - 2)! = 8! / 4! = 5 * 6 * 7 * 8 = 1680 permutations. For this simple image alone your server would have to test all 1680 permutations to find out the correct file name. This translates to a third of a second. If you have a longer filename like oriental-carpet-oc12345-closeup-small.jpg you are looking at millions upon millions of permutations. So even if what you wanted was possible with .htaccess rules (it's NOT) your site would be so dead slow that you'd be looking for a way to make it faster. And the only such way would be, you guessed it, editing all 700 products.

Also, FYI, the block of code you pasted is the code required by Joomla! to have SEF URLs. If you would remove it you would have no SEF URLs such as http://www.example.com/products/carpets.html. You would instead need to have ugly URLs such as http://www.example.com/index.php?option=com_eshop&view=categories&task=show&cat_id=1234&layout=carousel. So even if you do away with .htaccess Maker and use Joomla!'s own .htaccess file (renaming htaccess.txt to .htaccess) you're still going to have the same code. On top of that this block of code DOES NOT have anything to do with the file case for the simple reason that you are trying to access a lowercase named file (image.jpg) with an uppercase name (IMAGE.jpg). Since your new server has a case-sensitive filesystem on a case-sensitive operating system the file you are requesting DOES NOT exist. If you're wondering, this is why it's being picked up by the Joomla! SEF URL section of the .htaccess: it only handles requests to files and folders which physically do not exist on your server.

So, let's recap. Your problem is with your operating system and your unfortunate naming choice of files. We can't offer support for anything except our own software, per the support policy you agreed to, therefore we have to close your ticket.

Nicholas K. Dionysopoulos

Lead Developer and Director

🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

Support Information

Working hours: We are open Monday to Friday, 9am to 7pm Cyprus timezone (EET / EEST). Support is provided by the same developers writing the software, all of which live in Europe. You can still file tickets outside of our working hours, but we cannot respond to them until we're back at the office.

Support policy: We would like to kindly inform you that when using our support you have already agreed to the Support Policy which is part of our Terms of Service. Thank you for your understanding and for helping us help you!