010*_*110 8 php subdomain laravel laravel-5 laravel-5.1
我正在尝试拥有一个管理子域名(像这样)
Route::group(['domain' => 'admin.localhost'], function () {
Route::get('/', function () {
return view('welcome');
});
});
Run Code Online (Sandbox Code Playgroud)
但是admin.localhost就像localhost一样.我该如何正确地做到这一点?
我在OSX上使用Laravel 5.1和MAMP
Bro*_*ary 17
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.";
});
Run Code Online (Sandbox Code Playgroud)
但是这个例子不会:
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";
});
});
Run Code Online (Sandbox Code Playgroud)