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

前端 未结 7 1145
粉色の甜心
粉色の甜心 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:58

    One of the parameters you can send to Router::url() (which is called by other methods like HtmlHelper::link() and Controller::redirect()) is 'ext'. Try setting this to 'html'. E.g:

    echo $this->Html->link('Products', array('controller' => 'products', 'action' => 'index', 'ext' => 'html'));
    

    or

    $this->redirect(array('controller' => 'products', 'action' => 'index', 'ext' => 'html'));
    

    If it works, try figuring out a way you can override Router::url() to add it in by default.

提交回复
热议问题