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

2020-02-12 09:03发布

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 do so through any of its routing techniques. Please help.

7条回答
劳资没心,怎么记你
2楼-- · 2020-02-12 09:35

Its quite Simple,Open file app/config/routes.php and just add

Router::parseExtensions('html', 'rss');

Above the line

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

Now you can access even your controller methods with .html extensions .

I hope it helps .

查看更多
登录 后发表回答