【发布时间】:2014-01-14 04:52:04
【问题描述】:
我想让我的 url 对 seo 友好。 www.example.com/posts/view/1 更改为 www.example.pl/:slug-:id。一切正常,但可能是我在路由方面做错了,因为在分页器中点击 url 后,url 是正确的,看起来像 www.example.pl/:slug-:id ,但出现错误
"The requested address 'www.example.pl/:slug-:id' was not found on this server."
我不知道怎么了。这是我的代码:
Router::connect(
'/:slug-:id',
array(
'controller' => 'posts',
'action' => 'view'
),
array(
'pass' => array('slug' , 'id'),
'id' => '[0-9]+'
)
);
在分页器视图中:
echo $this->Html->link($ad['Post']['title'], array(
'controller' => 'posts',
'action' => 'view',
'slug' => Inflector::slug($post['Post']['title'],'-'),
'id'=>$post['Post']['id'])
);
我解决了这个问题。
【问题讨论】:
标签: php cakephp url-routing friendly-url