1

While I was learning kohana and making single article, i encountered this problem.

I wanted to get my url to look like article/post_id/slug(optional) so I made the route.

Route::set('article', '/<controller>/<article_id>(/<article_slug>(/<id1>(/<id2>(/<id3>))))', array('article_id' => '[0-9]', 'article_slug' => '[a-zA-Z0-9_]+')) ->defaults(array( 'controller' => 'article', 'action' => 'read', ));

I even tried without 3rd parameter for Route::set but anyway returns error shown in the picture.

Error Mesage

Thanks. (:

Raimonds
  • 2,606
  • 3
  • 20
  • 25

1 Answers1

1

Try without the leading /:

Route::set('article', '<controller>/<article_id>(/<article_slug>(/<id1>(/<id2>(/<id3>))))', 
array(
   'article_id' => '[0-9]', 
   'article_slug' => '[a-zA-Z0-9_]+')
)->defaults(
array( 
   'controller' => 'article', 
   'action' => 'read', 
));
matino
  • 17,199
  • 8
  • 49
  • 58
  • after following @matino's advice you wil probably want to add a plus-sign to the article_id regex – Darsstar Oct 03 '11 at 22:14
  • I tried without but still got this error, even tried to remplate `` width `article/` but still nothing – Raimonds Oct 04 '11 at 12:53
  • Maybe you have other route that match the URL before article route is executed? Try commenting all routes except article and see if this helps. – matino Oct 04 '11 at 13:20
  • This is the first defined route, [link](https://github.com/raimonds1503/vidfolio/blob/master/application/bootstrap.php) is the `bootstrap.php` file – Raimonds Oct 04 '11 at 13:37
  • It works perfectly on my computer... Have you added the + as suggested by @Darsstar? Just saw your bootstrap - I think you need to set index_file to FALSE ('index_file' => FALSE). – matino Oct 04 '11 at 13:48
  • Changed everything as needed index_file => false and route to `Route::set('article', 'article/(/(/(/(/))))', array('article_id' => '[0-9]+', 'article_slug' => '[a-zA-Z0-9_]+')) ->defaults(array( 'controller' => 'article', 'action' => 'read', )); ` but still nothing, maybe somethings wrong with my local server config? – Raimonds Oct 04 '11 at 14:07
  • Are you sure you have read action in your controller? The picture you gave says you don't ;) – matino Oct 04 '11 at 14:13
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/4000/discussion-between-matino-and-raimonds) – matino Oct 04 '11 at 14:13