Welcome Guest, Not a member yet? Register   Sign In
A problem with routing (multiple wildcards?)
#1

[eluser]#1313[/eluser]
Hello everybody, another newbie coming up!

My site has a cars catalogue, and i want to produce following URIs for my cars:
Code:
http://site.com/cars/lamborgini
and for specific models:
Code:
http://site.com/cars/lamborgini/murcielago

I have following functions in my Cars controller, car_maker() and car_model(), and a simple rule in routes.php:
Code:
$route['cars/:any'] = "cars/car_maker";
which succesfully sends control to car_maker function. Great, i can read about Lamborginis.

But now i want to read a page about Lamborgini Murcielado. I want to add a routing rule to launch car_model function, but i don't know how to write a rule with multiple wildcard characters properly. I tried
Code:
$route['cars/:any/:any'] = "cars/car_maker/car_model";
but this isn't working. How do i do this?
#2

[eluser]#1313[/eluser]
Whoops, i solved this question by myself =)

Code:
$route['cars/([a-z_\-]+)/(.+)'] = "cars/car_model/$1/$2";
$route['cars/:any'] = "cars/car_maker";

Worked perfectly.




Theme © iAndrew 2016 - Forum software by © MyBB