CakePHP custom route pagination

2019-07-02 08:07发布

问题:

I would like to format my URL like so:

/news/index/page:2

to

/news/2

I would like to achieve this result by using as less code as possible (perhaps only from routes.php?), without modifying how the PaginatorHelper behaves.

Thank you for your help!

回答1:

This should work

// Add this to /app/config/routes.php
Router::connect('/news/:page', array('controller' => 'news', 'action' => 'index'));