我可以让在 Windows 上运行的 Apache 区分大小写吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/507156/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 17:12:50  来源:igfitidea点击:

Can I make an Apache running on Windows case-sensitive?

windowsapachefile

提问by f3lix

The Windows file-systems (FAT, NTFS) do not care about the case of file names (case-insensitive). Consequently programs - like the Apache web server - running on windows handle file case-insenstive.

Windows 文件系统(FAT、NTFS)不关心文件名的大小写(不区分大小写)。因此,在 Windows 上运行的程序——比如 Apache Web 服务器——处理文件不区分大小写。

When you create web sites on Windows you inadvertently create links, etc. that do not match the case of the actual file name. You usually notice this mistakes not until you deploy the website onto case-sensitive file systems (as default on Linux, UNIX, ...).

当您在 Windows 上创建网站时,您会无意中创建与实际文件名大小写不匹配的链接等。您通常在将网站部署到区分大小写的文件系统(Linux、UNIX 等的默认设置)后才会注意到此错误。

Now, I would like to know if there is a way avoid these kind of mistakes by making the Apache web server somehow care about case even if the file-system does not care. I mean NTFS does differ between upper-case and lower-case letters in file names, so it should be theoretically possible to check whether file names match in a case-sensitive manner.

现在,我想知道是否有办法通过使 Apache Web 服务器以某种方式关心大小写来避免此类错误,即使文件系统不关心。我的意思是 NTFS 文件名中的大写和小写字母确实不同,因此理论上应该可以以区分大小写的方式检查文件名是否匹配。



I know that naming conventions like "Only use lowercase" can help avoiding these kind of problems, but that does not help with existing files and is less convenient :-)

我知道像“只使用小写字母”这样的命名约定可以帮助避免这类问题,但这对现有文件没有帮助,而且不太方便:-)

Also, not using Windows is not an option. I do not use Windows voluntarily and running the Apache on a different platform is not possible in this case.

此外,不使用 Windows 也不是一种选择。我不会主动使用 Windows,在这种情况下不可能在不同的平台上运行 Apache。

采纳答案by Rob Prouse

As far as I know you can't, but I will watch this question for other answers.

据我所知你不能,但我会看这个问题以获得其他答案。

As a workaround, you say that you must develop on Windows. What about installing Linux in a Virtual PC. There are several free VM programs like VirtualBoxand Microsoft Virtual PC. That way, you can match your development environment to your deployment environment.

作为一种解决方法,您说您必须在 Windows 上进行开发。在 Virtual PC 中安装 Linux 怎么样?有几个免费的 VM 程序,例如VirtualBoxMicrosoft Virtual PC。这样,您就可以将开发环境与部署环境相匹配。

Beyond that, I find that it is best to just make sure you use lowercase for everything, minimizing mistakes.

除此之外,我发现最好确保对所有内容都使用小写字母,以尽量减少错误。

回答by Luca

According to Apache documentation, it is not possible, because case insensitivity is embedded in Windows OS. But you can "reverse the problem" and turn the Apache server under Linux/Unix being case insensitive. Just add the following directives to your .htaccess:

根据 Apache 文档,这是不可能的,因为 Windows 操作系统中嵌入了不区分大小写的功能。但是您可以“扭转问题”并将Linux/Unix 下的Apache 服务器设为不区分大小写。只需将以下指令添加到您的 .htaccess 中:

RewriteEngine On
RewriteMap lowercase int:tolower
RewriteCond %{REQUEST_URI} [A-Z]
RewriteRule (.*) ${lowercase:} [R,L]

See the documentation here.

请参阅此处的文档。

回答by Robert

So it is now possible to do this on windows 10 https://www.windowscentral.com/how-enable-ntfs-treat-folders-case-sensitive-windows-10

因此,现在可以在 Windows 10 https://www.windowscentral.com/how-enable-ntfs-treat-folders-case-sensitive-windows-10上执行此操作

fsutil.exe file SetCaseSensitiveInfo C:\folder\path enable

fsutil.exe 文件 SetCaseSensitiveInfo C:\folder\path enable

回答by Ryan Guill

It seems you can enable mod_spelling with directive CheckSpelling on in Apache configuration file.

似乎您可以在 Apache 配置文件中使用指令 CheckSpelling 启用 mod_spelling。

Information and context found here: http://bytes.com/topic/apache/answers/608164-apache-case-sensitive-urls

信息和上下文在这里找到:http: //bytes.com/topic/apache/answers/608164-apache-case-sensitive-urls

Edit: the above was quoted for the reverse of the question, I am sorry. Someone does ask the same question that you do after that but never responds if the answer works or not. After looking further, there really doesn't seem to be a flag or any setting in apache itself to do this. Some people suggest trying to make the file system case-sensitive which does seem to be possible, but it looks like it causes more problems especially with other programs that are not expecting this.

编辑:上面引用了问题的反面,对不起。有人确实会问你在那之后做的同样的问题,但无论答案是否有效,他们都不会回答。进一步观察后,apache 本身似乎确实没有标志或任何设置来执行此操作。有些人建议尝试使文件系统区分大小写,这似乎是可能的,但看起来它会导致更多问题,尤其是对于其他不期望这一点的程序。

Overall, if you cannot develop on another OS and you cannot go through and change all of your existing filenames to be lowercase (which is understandable), then it doesn't look like you really have many options. The only suggestion I would give you at this point is to try and get a testing environment, set up exactly the same as your production environment and test as much as possible before sending to production.

总的来说,如果你不能在另一个操作系统上开发,并且你不能把你现有的所有文件名都改成小写(这是可以理解的),那么看起来你真的没有很多选择。在这一点上,我给你的唯一建议是尝试获得一个测试环境,设置与你的生产环境完全相同的环境,并在发送到生产环境之前尽可能多地进行测试。

Sorry for the misunderstanding and that I can't be of more help.

很抱歉造成误解,我无法提供更多帮助。

回答by an0nym0usc0ward

NTFS actually does support case sensitive file names. It is used and enabled by Microsoft's Services for UNIX. It is controlled in the registry. Do a google on the "ObCaseinSensitive" registry key. e.g. msdn blogand in particular this microsoft KB article: kb817921

NTFS 实际上确实支持区分大小写的文件名。它由 Microsoft 的 UNIX 服务使用和启用。它在注册表中控制。对“ObCaseinSensitive”注册表项进行谷歌搜索。例如msdn 博客,尤其是这篇微软知识库文章:kb817921

回答by BobbyShaftoe

This is not a problem you can solve the way you want. You need to upload your files by forcing lower case. You will avoid the naming conflict problem on Windows so if you are building things on Windows then you won't have to worry about that. Now, you need to use some sort of link checking program to find URLs that contain capital letters and then replace with lowercase equivalent.

这不是您可以按照自己的方式解决的问题。您需要通过强制小写来上传文件。您将避免 Windows 上的命名冲突问题,因此如果您在 Windows 上构建东西,则不必担心。现在,您需要使用某种链接检查程序来查找包含大写字母的 URL,然后将其替换为等效的小写字母。

However, Ryan Guill did make a good suggestion to enable CheckSpelling.

但是,Ryan Guill 确实提出了启用 CheckSpelling 的好建议。

回答by Lingfeng Xiong

Windows, CAN be set to case-sensitive mode. NTFS volume is also support case-sensitive mode. If you installed UNIX interoperability before, your Windows possibly already turned into case-sensitive mode. I believe there is a switch in registry, but I forgot where it is, so I can't figure it our for you. :-(

Windows,可以设置为区分大小写模式。NTFS 卷也支持区分大小写的模式。如果您之前安装了 UNIX 互操作性,您的 Windows 可能已经变成了区分大小写的模式。我相信注册表中有一个开关,但我忘记了它在哪里,所以我无法为您找到它。:-(