.htaccess 或其他 URL 区分大小写
我的服务器是区分大小写的,我想将其改为 inSensitive。
我的意思的例子是
假设我上传 Fruit.php
那么访问这个文件将不起作用:
www.website.com/fruit.php
但是这个会:
www.website.com/Fruit.php
有没有办法让 Fruit.php 和fruit.php 一起工作?还有目录。 IE:
/Script/script.php
/script/Script.php
My server is Case Sensitive, and id like to turn it to inSensitive.
Example of what I mean is
lets say I upload Fruit.php
Well then going to this file wont work:
www.website.com/fruit.php
but this one will:
www.website.com/Fruit.php
Is there a way so Fruit.php and fruit.php will work? also with the directories. i.e:
/Script/script.php
/script/Script.php
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您需要使用 mod_speling (sic) apache 模块:
http://httpd.apache .org/docs/1.3/mod/mod_speling.html
在 .htaccess 中,
CheckSpelling 操作使 Apache 执行更复杂的工作来查找匹配项,例如纠正常见的拼写错误
You need to use the mod_speling (sic) apache module:
http://httpd.apache.org/docs/1.3/mod/mod_speling.html
In .htaccess
The CheckSpelling operative makes Apache perform a more involved effort to find a match e.g. correcting common spelling mistakes
区分大小写取决于文件系统,而不是 Apache。然而,有一个部分解决方案。 mod_rewrite 可以将所有内容强制为小写(或大写),如下所示:
参考: http ://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewritemap
不幸的是,这仅在所有文件均为小写且指定混合大小写文件名(Fruit.php)时才有效。可以轻松地将项目中的所有文件重命名为小写吗?
Case sensitivity depends on the file system, not Apache. There is a partial solution, however. mod_rewrite can coerce everything to lowercase (or uppercase) like so:
Reference: http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewritemap
Unfortunately, this only works if all your files are lowercase, while you specifies mixed case filenames (Fruit.php.) Are you comfortable renaming all the files in your project lowercase?
UNIX 服务器区分大小写 - 它们区分文件名和文件夹名称中的大写和小写字母。因此,如果您将网站从 Windows 移动到 UNIX 服务器(例如,当您更改 Web 主机时),您可能会遇到一定数量的“找不到页面”错误(404 错误),因为目录和其他网站链接到您有时会弄错大小写(通常将文件夹名称的首字母大写等)。这个基于 javascript 的自定义 404 错误页面通过将 URL 转换为小写来解决该问题。
您可以从 http://www.forbrugerportalen.dk/sider/404casescript.js< 获取脚本/a>
编码愉快!!!!!!
UNIX-servers are case-sensitive - they distinguish between upper-case and lowercase letters in file names and folder names. So if you move your website from a windows to a UNIX-server (when you change web host for instance), you risk getting a certain amount of "Page not found"-errors (404 errors), because directories and other websites linking to yours sometimes get the cases wrong (typically writing the first letter of folder names in upper-case etc.). This javascript-based custom 404-error page solves the problem by converting URL's into lowercase.
You can get the script from http://www.forbrugerportalen.dk/sider/404casescript.js
Happy coding !!!!!!!