Make Folders in Apache Case Insensitive using .htaccess

故事扮演 提交于 2019-12-04 12:30:23

You have to install and enable the mod_speling module in apache and set the CheckCaseOnly Directive to On in your .htaccess

CheckCaseOnly On

If you want requested URLs to be valid whether uppercase or lowercase letters are used, use mod_speling to make URLs case-insensitive. Write the following code in .htaccess file:

CheckSpelling On

This is what I used because my hosting is shared and does not include the mod_spelling module but does support .htaccess, but this only works for one folder:

RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^student-government/$ http://www.tombarrasso.com/Student-Government/ [R=302,NC,L]

The folder to redirect to can be any case, so you could use lower-case folders and redirect all variations of spelling there.

I suppose it could be adapted with a little bit of REGEX to work for all folders rather than just one. This worked for me on Apache 2.2.14 (Unix).

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