CodeIgniter Forums

Full Version: hwo to set URI router Case-insensitive ?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2

El Forum

[eluser]RING[/eluser]
i set router in /app.../config/routes.php

Code:
$route['member(.*)'] = "member$1";
$route['(.*)'] = "home/$1";

the URL :
http://domain.com/member -->> class: Member , method:index()
http://domain.com/someword -->> class: Home , methodConfusedomeword()

but the URL like this :
http://domain.com/Member -->> class: Home , method:member()
http://domain.com/mEmber -->> class: Home , method:member()
in fact i want to access the class "Member",


hwo to set URI router Case-insensitive ?


another question:
how can i use some route setting, and i do NOT want it go into effect in any else CLASS ?

El Forum

[eluser]xwero[/eluser]
Code:
$route[sql_regcase('member').'(.*)'] = "member$1";
$route['[mM][eE][mM][bB][eE][rR](.*)'] = "member$1"; // this is what sql_regcase does

El Forum

[eluser]TheFuzzy0ne[/eluser]
Try something like this:
Code:
$route['/member(.*)/i'] = "member$1";

El Forum

[eluser]xwero[/eluser]
[quote author="TheFuzzy0ne" date="1236699785"]Try something like this:
Code:
$route['/member(.*)/i'] = "member$1";
[/quote]
That wouldn't work because the router uses this code to check the routes
Code:
if (preg_match('#^'.$key.'$#', $uri))
The line is found in the _parse_routes method

El Forum

[eluser]TheFuzzy0ne[/eluser]
The only other (more hacky way) I can think of, would be to do this:
Code:
$route['[Mm][Ee][Mm][Bb][Ee][Rr](.*)'] = "member$1";

Hope this helps.

El Forum

[eluser]xwero[/eluser]
TheFuzzy0ne look at response #1 Smile

El Forum

[eluser]TheFuzzy0ne[/eluser]
lol, thanks. I kinda missed that... I never heard of sql_regcase until today, so thanks for pointing that out.

El Forum

[eluser]RING[/eluser]
[quote author="xwero" date="1236699645"]
Code:
$route[sql_regcase('member').'(.*)'] = "member$1";
$route['[mM][eE][mM][bB][eE][rR](.*)'] = "member$1"; // this is what sql_regcase does
[/quote]

GOOD answers

El Forum

[eluser]RING[/eluser]
and.....
how can i use some route setting, and i do NOT want it go into effect in any else CLASS ?

El Forum

[eluser]TheFuzzy0ne[/eluser]
Please refine your question.
Pages: 1 2