G20map
G20map

Reputation: 99

Cakephp rerouting

Hi I d'like to be able to rewrite my url. I have this format of url:

localhost/example/urlrewriting/Links/view/1

and I want to change this url to

http://localhost/example/urlrewriting/tt/my-link-1

In my Routes.php I have done this:

    Router::connect('tt/:slug-:id',
    array('controller' =>'links', 'action' => 'test'),
    array('pass' => array('slug', 'id'), 'slug' => '[a-z0-9\-]+', 'id' => '[0-9]+'));

and in my controller I have this

    public function test($param1, $param2){
    debug($this->request->params);
}

I've always find this answer:

TtController could not be found.

cakephp 2.4.1

Upvotes: 0

Views: 81

Answers (1)

Vikash Pathak
Vikash Pathak

Reputation: 3562

Please add / before the connect params like:-

Router::connect('/tt/:slug-:id',
array('controller' =>'links', 'action' => 'test'),
array('pass' => array('slug', 'id'), 'slug' => '[a-z0-9\-]+', 'id' => '[0-9]+'));

Upvotes: 2

Related Questions