Case Insensitive Routing in CodeIgniter

前端 未结 8 954
南笙
南笙 2021-01-13 21:46

I\'ve written this in the CodeIgniter\'s routers.

$route[\'companyname\'] = \"/profile/1\";

This is working fine but when I type \"CompanyN

8条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-13 22:17

    The easiest way I could think of is to enforce lowercase urls with mod_rewrite (if you're using apache...)

    RewriteMap  lc int:tolower
    RewriteCond %{REQUEST_URI} [A-Z]
    RewriteRule (.*) ${lc:$1} [R=301,L]
    

    Source: http://www.chrisabernethy.com/force-lower-case-urls-with-mod_rewrite/

提交回复
热议问题