Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Laravel 使用多个路由组时RouteCollection中的NotFoundExeception_Laravel_Laravel 5 - Fatal编程技术网

Laravel 使用多个路由组时RouteCollection中的NotFoundExeception

Laravel 使用多个路由组时RouteCollection中的NotFoundExeception,laravel,laravel-5,Laravel,Laravel 5,我在RouteServiceProvider.php中定义了此映射实现: public function map(Router $router, Request $request) { $locale = $request->segment(1); $this->app->setLocale($locale); $router->group(['prefix' => '{lang}'], function($router) {

我在
RouteServiceProvider.php
中定义了此映射实现:

public function map(Router $router, Request $request)
{
    $locale = $request->segment(1);
    $this->app->setLocale($locale);

    $router->group(['prefix' => '{lang}'], function($router) {
        require app_path('Http/routes.php');
    });
}  
app/routes.php中,我还定义了一个路由组

Route::group(['prefix' => 'admin', 'middleware' => 'auth'], function (){

//code

);
现在,当我尝试访问
admin/xxx
时,它会显示此异常

NotFoundHttpException in RouteCollection.php line 161:
我试图将第一个路由组的定义放在
routes.php
中,但没有成功


如何解决这个问题?

定义到
RouteServiceProvider.php中的组排在定义到
routes.php中的组之前

因此,您应该这样访问您的路线:

xxx/admin

我举一个例子。现在默认url以/Lang开头。如果我写/Lang/admin/dashboard,它将重定向到/Lang/dashboard。相反,如果我写/Lang/403,它不在路由组中,它是OK的问题在于
auth
中间件。如果用户未经过身份验证,它将在哪个uri中重定向?(可能是
仪表板
)即使我通过/lang/auth/login登录,它也会重定向到/lang/login并显示错误..在添加lang前缀之前,一切都很顺利..似乎没有看到带有admin前缀的路由..但我不知道为什么。。