php - Laravel - multiple routes -


i'm doing simple project. want minimal possible tried create system can create pages , they're placed @ localhost/{page?}

but, here's problem. want routes defined (e.g. route /blog) below.

route::get('/{page?}', ['as' => 'root', 'uses' => 'sitecontroller@getroot']);  route::get('blog/{slug?}', ['as' => 'blog.post', 'uses' => 'blogcontroller@getpost']); route::get('blog/page/{page}', ['as' => 'blog.page', 'uses' => 'blogcontroller@getpage'])->where('page', '[0-9]+'); 

with setup, uses first route.

my question is. there way this? or, beyond capabilities of laravel?

thank help.

yeah, place first route last route. way picked last. may need place blog/{slug?} before 1 blog/slug/{page} first.

route::get('blog/page/{page}', ['as' => 'blog.page', 'uses' => 'blogcontroller@getpage'])->where('page', '[0-9]+');  route::get('blog/{slug?}', ['as' => 'blog.post', 'uses' => 'blogcontroller@getpost']);  route::get('/{page?}', ['as' => 'root', 'uses' => 'sitecontroller@getroot']); 

basically happens basic route picking other routes because there no reason not , technically matches route though it's not route want. putting specific routes first handles issue.


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -