Sure. The only requirement for this is that there is enough unique information in the URL to bind the desired article. If /article-name is unique in your database, you can use it to search for the required entry.
In config / routes.php:
// ... configure all normal routes first ... Router::connect('/*', array('controller' => 'articles', 'action' => 'view'));
In the / articles _controller.php controllers:
function view ($article_name) { $article = $this->Article->find('first', array( 'conditions' => array('Article.name' => $article_name) )); ... }
Be careful not to name your products like anything that could legitimately appear in a URL, so you don't run into conflicts. Does the URL http://example.com/pages to product pages or to an array('controller' => 'pages', 'action' => 'index') ? To do this, you will also need to define your routes in routes.php so that all your controllers are available in the first place, and only the undefined rest will be transferred to your ArticlesController . Take a look at the third parameter, Routes::connect , which allows you to specify a RegEx filter that you could use for this purpose.
source share