duan1396 2014-01-30 06:03
浏览 58
已采纳

定义路由中的Laravel NotFoundHttpException

i have this below route and that can work correctly

Route::get('admin/login', array('as'=>'login', function()
{
    return View::make('back_end.login');
}));

structure of my web:

app
    views
        back_end
            layouts
                index.blade.php
                main.blade.php
                profile.blade.php
            login.blade.php

for admin i have any view for show and i want to grouping that with admin perfix. after this action and use

http://localhost/laravel/public/admin/login or http://localhost/laravel/public/admin/profile URL, i get this error:

 Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException 

this is my routes:

Route::group(array('prefix' => 'admin','before' => 'auth'), function()
{
    Route::get('/login', function()
    {
        return View::make('back_end.login');
    });

    Route::get('/index', array('as'=>'dashboard'), function()
    {
        return View::make('back_end.layouts.index');
    });

    Route::get('/profile', function()
    {
        return View::make('back_end.layouts.profile');
    });
});

composer dump-autoload command could not fix and this is that result:

Generating autoload files

how to fix this routes. please help me

  • 写回答

1条回答 默认 最新

  • dsaob80228 2014-01-30 13:46
    关注

    You just need to remove the slashes and it should work as expected

    Route::group(array('prefix' => 'admin','before' => 'auth'), function()
        {
        Route::get('login', function() // <---------   for admin/login
        {
            return View::make('back_end.login');
        });
    
        Route::get('index', array('as'=>'dashboard'), function()  // <---------   for admin/index
        {
            return View::make('back_end.layouts.index');
        });
    
        Route::get('profile', function()  // <---------   for admin/profile
        {
            return View::make('back_end.layouts.profile');
        });
    });
    

    ofcourse after modification of routes.php run composer dump-autoload.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试,帮帮忙吧
  • ¥15 #MATLAB仿真#车辆换道路径规划