How can I append .html to all my URLs in cakephp?

前端 未结 7 1114
粉色の甜心
粉色の甜心 2020-12-19 11:18

I am using cakephp in one of my projects and my client wants the site URLs to end with .html and not the usual friendly urls. I was wondering if its possible in cakephp to d

7条回答
  •  隐瞒了意图╮
    2020-12-19 11:46

    Had to solve this without using Routes. Kept the default route entry for pages:

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

    and in the display action removed the .html extension and rendered the respective view:

    preg_replace('/\.html$/','',$view);
    $this->render(null,'default',$view);
    

    While calling the pages added 'ext' to be .html

提交回复
热议问题