Laravel - Using (:any?) wildcard for ALL routes?

前端 未结 8 1184
时光取名叫无心
时光取名叫无心 2020-11-29 03:18

I am having a bit of trouble with the routing.

I\'m working on a CMS, and i need two primary routes. /admin and /(:any). The admin

8条回答
  •  粉色の甜心
    2020-11-29 03:39

    Route::get("{path}", "SomeController@serve")->where('path', '.+');
    

    The above code will capture the recursive sub urls you mentioned:

    /
    /something
    /something/something
    /something/something/something
    /something/something/something/something
    

    Any other special cases, such as admin/*, you can capture before this one.

提交回复
热议问题