duanbamo0127 2018-07-26 10:15
浏览 47
已采纳

Laravel多变量子子域

Currently I have:

Route::domain('{subdomain}.alfa.example.com')->group(function () {

    Route::get('/tet', function ($subdomain) {

        dd($subdomain); 

    });
})

I want to be able to use a route that will respect the following criteria:

  • {variable}.alfa.example.com
  • {variable 1}. (...) .{variable N}.alfa.example.com
  • Variable is not known or defined.
  • N is also not defined and I can have as many dots as I can (as many sub sub domains as I can)

Before asking, I have tried to use ->where('subdomain', '(.*)'); but with no effect.

  • 写回答

1条回答 默认 最新

  • dongyun8075 2018-07-26 10:21
    关注
    Route::domain('{subdomain}.alfa.example.com')->group(function () {
    
        Route::get('/tet', function ($subdomain) {
    
            dd($subdomain); 
    
        })->where('subdomain', '(.*)');
    });
    

    After all I have used ->where('subdomain', '(.*)')

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?