multiple routes in single Route::get() call Laravel 4

后端 未结 3 1471
-上瘾入骨i
-上瘾入骨i 2020-12-06 17:22

When defining a route in Laravel 4 is it possible to define multiple URI paths within the same route?

presently i do the following:

Route::get(\'/\'         


        
3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-06 17:40

    I believe you need to use an optional parameter with a regular expression:

    Route::get('/{name}', array(
         'as' => 'dashboard', 
         'uses' => 'DashboardController@index')
        )->where('name', '(dashboard)?');
    

    * Assuming you want to route to the same controller which is not entirely clear from the question.

    * The current accepted answer matches everything not just / OR /dashboard.

提交回复
热议问题