我正在尝试拥有一个管理子域(像这样 https://laravel.com/docs/5.1/routing#route-group-sub-domain-routing)
Route::group(['domain' => 'admin.localhost'], function () {
Route::get('/', function () {
return view('welcome');
});
});
but 管理员.localhost http://admin.localhost行为就像本地主机 http://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";
});
});
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)