如何更改kohana 3.2中的默认网址格式。
base / news / news_details to news /
Route::set('news_tracking2', 'news/news_details')
->defaults(array('controller' => 'news','action' => 'index','method' => NULL));
答案 0 :(得分:0)
你混合概念。有一个路由将传入的URL转换为Request::controller-action
(1)。并为HTML(2)生成链接。
1:对于路线:
Route::set('second', 'awesome_news_prefix(/<id>(/<offseet>))', array('offset' => '[1-9]\d*(\.\d+)?'))
->defaults(array(
'controller' => 'news',
'action' => 'index',
'id' => NULL,
'offset' => NULL,
));
Route::set('default', '(<controller>(/<action>(/<id>(/<offseet>))))', array('controller' => '[a-z][^/\.]+', 'offset' => '[1-9]\d*(\.\d+)?'))
->defaults(array(
'controller' => 'news',
'action' => 'index',
'id' => NULL,
'offset' => NULL,
));
链接生成
URL :: site(Route :: get(&#39;默认&#39;) - &gt; uri(数组(&#39; id&#39; =&gt; 1)));
< / LI> 醇>给出结果:http://example.com/news/index/1
URL::site(Route::get('second')->uri(array('id' => 1)));
给出结果:http://example.com/awesome_news_prefix/1