如何将.html附加到cakephp中的所有网址?

前端之家收集整理的这篇文章主要介绍了如何将.html附加到cakephp中的所有网址?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我在我的一个项目中使用cakePHP,我的客户希望站点URL以.html而不是通常的友好URL结尾.我想知道在cakePHP中是否可以通过它的任何路由技术来实现.请帮忙.

解决方法

这在 cookbook中有详细记载.

更新:http://book.cakephp.org/2.0/en/development/routing.html#file-extensions

To handle different file extensions with your routes,you need one
extra line in your routes config file:

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

If you want to create a URL such as /page/title-of-page.html you would
create your route as illustrated below:

Router::connect(
    '/page/:title',array('controller' => 'pages','action' => 'view'),array(
        'pass' => array('title')
    )
);

Then to create links which map back to the routes simply use:

$this->Html->link(
    'Link title','action' => 'view','title' => 'super-article','ext' => 'html')
);

猜你在找的HTML相关文章