[ASK] About URI Routing |
[eluser]senz[/eluser]
Hi all, I wanna ask about URI Routing. I just create the simple controller category.php and the code like this : Code: <? Ex : 1. http://localhost/codeigniter/category/health 2. http://localhost/codeigniter/category/he...op_smoking I just edited the routes.php to and the code like this : Code: <? http://localhost/codeigniter/category/health => the result is : health and when i write : http://localhost/codeigniter/category/he...op_smoking => the result is still health and not stop_smoking My question is how can i pass the 3rd parameter?
[eluser]mddd[/eluser]
(:any) will match ANYTHING! So if you ask for /category/health/smoking, that url will match the first rule and be rewritten to /category/first/health/smoking. You should reverse the order of your rules. That way, it is first checked if there is a url with two parts after 'category'. If that is not matched, the rule with one part after 'category' is tried.
[eluser]senz[/eluser]
Can you explain with the code. Sorry i'm newbie and i didn't get it what you say... How should i write in routes and controller?...
[eluser]mddd[/eluser]
The problem is that (:any)/(:any) is a match to "health/smoking", but (:any) also is a match to "health/smoking" ! So, the rule that you put first will match. To get $1 and $2 correct, you must make sure that the rule with (:any)/(:any) is the first one in the file. Code: <?
|
Welcome Guest, Not a member yet? Register Sign In |