Getting rid of that extra /pages/ in your URL for static pages using CakePHP

So I’m just learning CakePHP, and I’m doing so by translating a site from html into Cake. Most of the pages are static pages, so I’m putting them into app/views/pages. Thing is, when I look at them in the browser, the name of the page is always preceded by that blasted pages/, and I wanted to get rid of that. I.e. I wanted to be I finally found how to do this, and figured I’d post it here for future reference purposes:

Locate routes.php, found in app/config/, and add this line:

Router::connect('*', array('controller' => 'pages', 'action' => 'display'));

That should eliminate the pages/ in the url for any of your .ctp files located in the pages directory.


Leave a Reply