CodeIgniter Forums

Full Version: Anyone know how to shorter the number of strings after the url by routing
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]Unknown[/eluser]
Hi.

I want to change the following url

example.com/board/view/$board_id
into
example.com/view/$board_id, or
example.com/$board_id

The thing is that I cannot change the three string urls into two or one string urls.

For example,
$route['view/:any']="board/view/$1";
is not working.


Whatever I put in, unless the number of strings after the url is same to
before the change, the routing is not working properly.

Does anyone know why? and is there any ways that I can change it from route.php?

El Forum

[eluser]keevitaja[/eluser]
Code:
$route['board/view/:any'] = "view/$1";

El Forum

[eluser]Unknown[/eluser]
[quote author="keevitaja" date="1348670957"]
Code:
$route['board/view/:any'] = "view/$1";
[/quote]

I don't know why mine is not working.

I initially tried what you stated, but it did not work.

very confused.

El Forum

[eluser]CroNiX[/eluser]
If you are going to use :any to capture a variable and pass it to the function, it has to be (:any) with the (). See the userguide for routing.