简体   繁体   English

忽略 .htaccess 文件中的大写或小写字母

[英]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.我在 Hostinger.com“PHP7.4”托管,我将其用作下载文件服务器。 fastdl type. fastdl 类型。 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.我在.htaccess中尝试了几种配置但没有成功。 Would anyone have any ideas, I remember I did it years ago but I don't remember how.谁有什么想法,我记得我几年前做过,但我不记得是怎么做的。

.htaccess .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. RewriteMap不能在.htaccess中定义,所以这个“应该”导致 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").但是,将请求的 URL 转换为小写不会帮助您,因为您需要将其转换为与基础文件(“未知”)相同的“驼峰式”。

mod_speling (one "l") is really your only option (short of renaming all your files) - providing this is installed on your server. mod_speling(一个“l”)确实是您唯一的选择(除了重命名所有文件)——前提是它已安装在您的服务器上。 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".应该使用CheckCaseOnly指令来避免 mod_speling 纠正其他“拼写错误”。

Reference:参考:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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