.htaccess or other URL Case Sensitive

这一生的挚爱 提交于 2019-11-29 05:18:31

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:

RewriteMap tolowercase int:tolower 
RewriteRule ^(.*)$ ${tolowercase:$1}

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?

You need to use the mod_speling (sic) apache module:

http://httpd.apache.org/docs/1.3/mod/mod_speling.html

In .htaccess

<IfModule mod_speling.c>
  CheckCaseOnly On
  CheckSpelling On
</IfModule>

The CheckSpelling operative makes Apache perform a more involved effort to find a match e.g. correcting common spelling mistakes

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 !!!!!!!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!