0
votes

on my website I use Cake PHP and I have an url like this for an article:

/article/testx?name=Stefy

I would like to do a kind of "mod rewrite" and have an url like this:

/name/Stefy

I tried to do it from routes.php but I don't know how to do. I checked on CakePHP website about "pass" function in array and other topics here on StackOverflow but I can't find a solution, probably because I am a beginner with CakePHP. Can you help me please?

I thought I should something like this: Router::connect('/name/:id', array('controller' => 'articoli', 'action' => 'display','testx?name=$id') );

but of course it doesn't work. I think I have to use "pass" in the routes.php

Can you help me?

Thank you!

2

2 Answers

0
votes

yeah, you kinda do have to use "pass":

Router::connect('/name/:id', 
    array('controller' => 'articoli', 'action' => 'display'), 
    array('pass' => array('id')));

you can than generate links like this:

$this->Html->link('Title', array('action' => 'display', 'id' => 1));
0
votes

Router::connect('/:slug',array('controller' => 'salons', 'action' => 'details'), array('pass' => array('slug')));