CodeIgniter Forums
CI Route question - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: CI Route question (/showthread.php?tid=66595)



CI Route question - jackcott - 11-09-2016

hi guys, i am new to Codelgniter.  I have a question for the CI url routing.
Here is CI user guide examples

example 1:
[font=Consolas, 'Andale Mono WT', 'Andale Mono', 'Lucida Console', 'Lucida Sans Typewriter', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Liberation Mono', 'Nimbus Mono L', Monaco, 'Courier New', Courier, monospace]$route['journals'] = 'blogs';
[/font]

A URL containing the word “journals” in the first segment will be remapped to the “blogs” class.

example 2:
[font=Consolas, 'Andale Mono WT', 'Andale Mono', 'Lucida Console', 'Lucida Sans Typewriter', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Liberation Mono', 'Nimbus Mono L', Monaco, 'Courier New', Courier, monospace]$route['blog/joe'] = 'blogs/users/34';
[/font]

A URL containing the segments blog/joe will be remapped to the “blogs” class and the “users” method. The ID will be set to “34”.

It works with example 1.  

But I try example 2,  use $this->uri->segment(3),  it cannot receive the parameter ID 34, the segment(3) is a NULL value,

[Image: 40642a856e.jpg]


How this work out? Thanks!


RE: CI Route question - salain - 11-10-2016

Hi,
Use rsegment as your url is re-routed.
See