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

[eluser]frietkot[/eluser]
Hi,

i figured that with uri routing you can use something like this:
http://www.example.com/user/$variable_user

and that works.

But now I have something like this:
http://www.example.com/$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

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

El Forum

[eluser]frietkot[/eluser]
Thanks,

That did the trick