Laravel - CNAME + Subdomain Routing

后端 未结 3 1333
悲&欢浪女
悲&欢浪女 2021-02-11 06:44

I have my routes set up as follows:

 \'{username}.u.\'.env(\'APP_DOMAIN\'),
], function () {
    Route::get(\'/\', \         


        
3条回答
  •  旧时难觅i
    2021-02-11 07:05

    You can't have a wildcard on the whole domain, at least not with one wildcard. What you can do is the following:

    Route::group([
        'domain' => '{domain}.{suffix}',
    ], function () {
        Route::get('/', 'FrontendController@domain');
    });
    

    Just make sure that this group is the last one in your routes file, it will act as a fallback group on domains and will serve the requests that don't match any of the previous domains.

    Also I'd recommend using this package, it might be helpful for what you are trying to do.

提交回复
热议问题