Laravel: How to respond with custom 404 error depending on route

后端 未结 1 803
北荒
北荒 2020-12-28 20:48

I\'m using Laravel4 framework and I came across this problem.

I want to display a custom 404 error depending on requested url.

For example:

R         


        
相关标签:
1条回答
  • 2020-12-28 21:15

    In app/start/global.php

    App::missing(function($exception) 
    {
        if (Request::is('admin/*'))
        {
            return Response::view('admin.missing',array(),404);
        }
        else if (Request::is('site/*'))
        {
            return Response::view('site.missing',array(),404);
        }
        else
        {
             return Response::view('default.missing',array(),404);
        }
    });
    

    In your view, you can find $something with {{ Request::path(); }} or {{ Request::segment(); }}

    0 讨论(0)
提交回复
热议问题