Welcome Guest, Not a member yet? Register   Sign In
URI routing?!
#1

[eluser]modano[/eluser]
hi everyone,

Its been over 6 months since i wrote any CI code, well any code at all actually.
I just started a new little project and i can for the love of god not get uri routing to work.
I even looked at an old project, and still i can not get it to work. been staring at this for hours now and figured, maybe someone can tell me what im doing wrong, or maybe i missed something in the installation?

What i want:
www.domain.com/shoes/adidas.html to go to the controller products and pass shoes and adidas as parameters.


What i have done:
1. Added the lines in htaccess to remove index.php from url
2. in route.php i have added: $route['shoes/(.+)']='products/index/$1';
3. created a controller named products and a function called index with optional input parameter.

If i enter www.domain.com/shoes/adidas/ it works, but if i enter www.domain.com/shoes/ it says page not found, it does not! go to the index function at all.
Notice that i used /adidas/ above, not /adidas.html as what i am trying to achieve, because im not sure how to get that to work, except i know it is the url_suffix in config.php

Would be grateful if anyone could help me out here,
thanks in advance
modano
#2

[eluser]wiredesignz[/eluser]
It looks as though you have set the regex to grab values that come after shoes/ ,not including it.
#3

[eluser]modano[/eluser]
and the correct way would be?
#4

[eluser]modano[/eluser]
got it, this seem to do the trick
$route['(shoes)/(:any)'] = 'products/index/$1/$2';
$route['(shoes)'] = 'products/index/$1';




Theme © iAndrew 2016 - Forum software by © MyBB