简体   繁体   中英

Ignore uppercase or lowercase letters in .htaccess files

I have hosting at Hostinger.com "PHP7.4" and I'm using it as a file server for download. fastdl type. However, certain files have capital letters mixed in the name, for example:

http://example.com.br/fouder/Emote_Dino_Complete.mp3.bz2

only the program I use to search for the files sometimes searches with lowercase letters:

http://example.com.br/fouder/emote_dino_complete.mp3.bz2

and does not download.

It would be simple just to change the name of the files but there are many. I tried several configurations in .htaccess but without success. Would anyone have any ideas, I remember I did it years ago but I don't remember how.

.htaccess

<IfModule mod_rewrite.c>
RewriteEngine on
rewritemap lowercase int:tolower
RewriteCond $1 [A-Z]
RewriteRule ^/(.*)$ /${lowercase:$1} [R=301,L]
CheckSpelling on
</IfModule> 
RewriteEngine on rewritemap lowercase int:tolower RewriteCond $1 [AZ] RewriteRule ^/(.*)$ /${lowercase:$1} [R=301,L]

RewriteMap s can't be defined in .htaccess , so this "should" result in a 500 Internal Server Error. However, converting the requested URL to lowercase is not going to help you since you would need to convert it to the same "camel case" as the underlying file (which is "unknown").

mod_speling (one "l") is really your only option (short of renaming all your files) - providing this is installed on your server. However, you have already (attempted to) enable this in your posted config file (although currently, your file is wholly invalid).

You would need just:

CheckSpelling On
CheckCaseOnly On

The CheckCaseOnly directive should be used to avoid mod_speling correcting other "spelling errors".

Reference:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM