1

How to changes the default URL format in kohana 3.2.

base/news/news_details to news/

Route::set('news_tracking2', 'news/news_details')
->defaults(array('controller' => 'news','action'  => 'index','method' => NULL));
arulraj
  • 105
  • 2
  • 12

1 Answers1

0

You mix the concepts. There is a routing that translates the incoming URL into Request::controller-action(1). And generate links for HTML (2).

1: For routes:

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,
   ));
  1. link generation

    URL::site(Route::get('default')->uri(array('id' => 1)));

give result: http://example.com/news/index/1

URL::site(Route::get('second')->uri(array('id' => 1)));

give result: http://example.com/awesome_news_prefix/1

bato3
  • 2,695
  • 1
  • 18
  • 26