Ilya Vo
Ilya Vo

Reputation: 2309

How to make laravel routing like in wordpress?

Strandart url - site.com/controller/func/parametr

You can make such constructions urls:

site.com/category/category1/post1
site.com/category/category1/post2
site.com/category/category2/post1

I would like to:

site.com/category1/post1
site.com/category2/post1

It is possible if i make controller for each category, but is so messy.

Upvotes: 1

Views: 751

Answers (1)

webNeat
webNeat

Reputation: 2828

You can do it just be defining a route like this

Route::get('/{cat}/{title}',array('uses' => 'PostsController@showPost'));

And then use the parameters in the action

public function showPost($cat, $title){
    // you can find category and post by titles and show the post
}

Upvotes: 4

Related Questions