1、 在文件目录中找到RouteServiceProvider.php 文件。在这个文件中,可以看到web.php,和api.php的路由都是在这个地方定义的。
2.我们要给后台新建一个admin.php的路由文件。先在RouteServiceProvider.php写上我们的路由方法。
/**
* Define the "api" routes for the application.
*
* These routes are typically stateless.
*
* @return void
*/
protected function mapAdminRoutes()
{
Route::prefix('admin')
->namespace($this->namespace)
->group(base_path('routes/admin.php'));
}
然后,将这个方法注册到map()方法当中。
这样写完,在routes新建admin.php路由文件。这样访问的时候,就要加上admin前缀。