【发布时间】:2010-01-19 12:53:29
【问题描述】:
我有一组相当静态的页面,我将它们移到了views/pages 文件夹中。我的客户可以通过 CushyCMS 编辑生成的 *.ctp 文件(简单的 cms 非常适合虚拟校样编辑)。然而,CushyCMS 生成的预览链接显然没有考虑到 CakePHP。我想用自定义路由来解决这个小问题,但无法理解细节......
如何动态连接网址http://localhost:8888/cake125/app/views/pages/test.ctp 到http://localhost:8888/cake125/pages/test?
我在 routes.php 中添加了以下内容:
Router::connect('/pages/test.ctp', array(
'controller' => 'pages',
'action' => 'display', 'test'));
这适用于连接:http://localhost:8888/cake125/pages/test.ctp 到 http://localhost:8888/cake125/pages/test。不知何故,跟随 snibbet 并不能解决问题:
Router::connect('/app/views/pages/test.ctp', array(
'controller' => 'pages',
'action' => 'display', 'test'));
理想情况下,我希望有一个 Router::connect 语句,它将所有 /app/views/pages/*.ctp 请求连接到正确的位置。
最后,我还想正确处理旧版网站的谷歌搜索结果。像这样:
Router::connect('/test.html', array(
'controller' => 'pages',
'action' => 'display', 'test'));
这没问题,但我宁愿让 anypage.html 连接到 /pages/anypage。有人可以帮忙吗?
提前致谢!
【问题讨论】: