I've been working on this for a few days...
When I visit a URL for a .jpg that doesn't exist, my site redirects me to a closed file (apparently there's a 1 character difference). For example: if 12345.jpg exists but 1234.jpg does not, 1234.jpg will redirect to 12345.jpg.
This website is not hosted on Wordpress or other similar platform. I took existing code and developed it. I can access all files and directories through Filezilla. I searched for .htaccess but none have a redirect line. I also tried removing .htaccess but same problem.
I was wondering, if we can't find the source of the problem, maybe some of you know how to write some code that locally prevents any redirects from happening?
Thank you very much for your help!
It sounds like you have
mod_speling
a> (al
) enabled in the server configuration.mod_speling
Scan directories when requesting files that do not exist. If there is a "close match" (e.g. 1 character difference), a 301 redirect will be issued to the file. (Although if there is more than 1 "close match" the user will be shown a list of available files!)You can disable this behavior in
.htaccess
using the following command:This option is disabled by default, so it needs to be explicitly enabled elsewhere in the server configuration. (If you have access, it's best not to enable it in the first place.)
Please note that since a 301 (permanent) redirect is issued, you will need to clear your browser (and any intermediate) cache before testing.
Aside:
CheckCaseOnly
directive (part of mod_speling) is more commonly used to limit spelling corrections to onlycase, ie. Enable case-insensitive URLs.