我正在尝试拥有一个管理子域名(像这样)
Route::group(['domain' => 'admin.localhost'], function () { Route::get('/', function () { return view('welcome'); }); });
但是admin.localhost就像localhost一样.我该如何正确地做到这一点?
我在OSX上使用Laravel 5.1和MAMP
Laravel以先来先服务的方式处理路线,因此您需要将最少的特定路线放在路线文件中.这意味着您需要将路由组放在具有相同路径的任何其他路由之上.
例如,这将按预期工作:
Route::group(['domain' => 'admin.localhost'], function () { Route::get('/', function () { return "This will respond to requests for 'admin.localhost/'"; }); }); Route::get('/', function () { return "This will respond to all other '/' requests."; });
但是这个例子不会:
Route::get('/', function () { return "This will respond to all '/' requests before the route group gets processed."; }); Route::group(['domain' => 'admin.localhost'], function () { Route::get('/', function () { return "This will never be called"; }); });