2014-08-28 100 views
1

Strandart网址 - site.com/controller/func/parametr如何在wordpress中制作laravel路由?

可以使这种结构的网址:

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

我想:

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

这是可能的,如果我做每个类别的控制器,但如此混乱。

回答

4

你可以这样做只是被定义路由这样

Route::get('/{cat}/{title}',array('uses' => '[email protected]')); 

然后用这些参数在动作

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