Why does my site automatically redirect to a different URL when accessing a file that doesn't exist, even without any .htaccess redirects?
P粉198670603
P粉198670603 2023-08-30 21:32:54
0
1
412

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!

P粉198670603
P粉198670603

reply all (1)
P粉166675898

It sounds like you havemod_spelinga> (al) enabled in the server configuration.

mod_spelingScan 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.htaccessusing the following command:

CheckSpelling Off

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:CheckCaseOnlydirective (part of mod_speling) is more commonly used to limit spelling corrections to onlycase, ie. Enable case-insensitive URLs.

    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!