Kees Sonnema
Kees Sonnema

Reputation: 5784

how to hide controller name using routes when you have an id segment?

I have an url like this:

http://kees.een-site-bouwen.nl/home/categorie/11

to show factories in a specific category.

I want to have an url like this:

http://kees.een-site-bouwen.nl/categorie/11

but when i use the url routing in my config/routes file like this:

$route['categorie'] = 'home/categorie';

it does not work. am i missing something?

The working link to the page is:

echo '<a href="'.base_url().'home/categorie/'.$value->idcategorieen.' ">' .$value->Categorie. '</a>';

The link that does not work is:

echo '<a href="'.base_url().'categorie/'.$value->idcategorieen.' ">' .$value->Categorie. '</a>';

Hope someone can help me :)

Upvotes: 0

Views: 79

Answers (2)

chandresh_cool
chandresh_cool

Reputation: 11830

You are missing to to mention the argument i.e 11 to like this

$route['categorie/(:num)']

Upvotes: 1

Svetoslav
Svetoslav

Reputation: 4686

$route['categorie/(:num)'] = 'home/categorie/$1';

Here is one easy, fast and clean route :)

Please read Documantation before asking.. CI Routing

Upvotes: 1

Related Questions