CodeIgniter Forums

Full Version: Uri re-routing doesn't work
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum


i figured that with uri routing you can use something like this:$variable_user

and that works.

But now I have something like this:$variablecity/news

and I have this in the routes.php file:
$route[':any/news'] = "news/city";

and that works too.
But here's the thing...

When I use the uri class and use $this->uri->segment(); or $this->uri->rsegment();
it returns nothing when I want to know the first segement (the city name in this case).

Any suggestions?

El Forum

You need to add the city name to the rerouted segments. For example like this
$route[’(:any)/news’] = “news/city/$1”;
Now the city name is the first parameter of the city method.

El Forum


That did the trick