apachemod-rewritefilesystemsfusemod-speling

Case insensitive file serving after internal redirect with mod_rewrite


I'm trying to serve files case-insensitively from an Apache server that requires the use of mod_rewrite to serve files from a subfolder.

.
├── .htaccess
├── example.com
│   └── downloads
│       └── file.zip
└── www.reddit.com
    └── r
        └── programming
            └── index.html

The server acts as a proxy and serves each folder depending on the HTTP Host variable. To do this, I use an .htaccess to perform a simple internal redirect.

The problem arises because it also needs to be case insensitive, I want to serve file.zip, FiLe.zip, FILE.ZIP etc.. For this I tried mod_speling, which almost works. The problem is that if I access FiLe.zip, I get redirected to http://example.com/example.com/downloads/file.zip, which is a 404.

As I understand it, mod_speling works in actual paths, so the result makes sense. However, it is not satisfactory.

Is there any way to rewrite the corrected path from mod_speling? If not, is there another possible way to accomplish this?

I also tried stacking a ciopfs fuse mount, a case insensitive overlay file system, but it fails to see the files because it skips them if they contain any uppercase characters.

I cannot configure each of these subfolders as a different virtual host because there are hundreds of these folders and they are added or removed on the fly.


Solution

  • Ended up writing my own FUSE file system as an alternative to ciopfs.

    https://github.com/XXLuigiMario/fuzzyfs

    This file system attempts to locate files by checking in the same directory for a different instance of the same filename but with different capitalization. Similarly to how mod_speling attempts to correct capitalization errors. To use it, you just need to give it a directory and a mount point:

    $ fuzzyfs /mnt/data /var/www/htdocs

    This mount point will mirror the given directory, except it will also perform as if its underlying file system were case insensitive. This tool requires FUSE to be installed on the system. To install fuzzyfs, clone it with git and run make && make install.