我正在尝试拥有一个管理子域(像这样)
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";
});
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句