我正在开发CakePHP,我有一个网址http://admin.example.com/Pages 如何创建http://admin.example.com/Pages.html?有没有解决这个问题的解决方案或组件?
答案 0 :(得分:1)
根据CakeBook,您可以定义要在路径中解析的扩展名
E.g。在app/Config/routes.php
Router::parseExtensions('html');
这将允许您在路径(url)中发送.html扩展
不创建链接
例如:
$this->Html->link('Link title', array(
'controller' => 'pages',
'action' => 'index',
'ext' => 'html'
));
当您点击该链接时,您将在浏览器中获得类似此内容的网址
答案 1 :(得分:0)
你真的需要这个吗? CakePHP自动呈现View
文件夹
PagesController
文件夹中创建(如果是index
和index.ctp
methond)app/View/Pages
,它将自动呈现。您可以使用file_get_contents函数来读取文件。像这样:
//在控制器中
function index(){
$ content = file_get_contents(' path / to / file.html');
echo $ content;
模具();
}