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

前端 未结 8 1211
时光取名叫无心
时光取名叫无心 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 04:02

    Laravel 5

    This solution works fine on Laravel 5:

    Route::get('/admin', function () {
    
      // url /admin
    
    });
    
    Route::get('/{any}', function ($any) {
    
      // any other url, subfolders also
    
    })->where('any', '.*');
    

    Lumen 5

    This is for Lumen instead:

    $app->get('/admin', function () use ($app) {
      //
    });
    
    $app->get('/{any:.*}', function ($any) use ($app) {
      //
    });
    

提交回复
热议问题