Laravel: How to respond with custom 404 error depending on route -
i'm using laravel4 framework , came across problem.
i want display custom 404 error depending on requested url.
for example:
route::get('site/{something}', function($something){ return view::make('site/error/404'); });
and
route::get('admin/{something}', function($something){ return view::make('admin/error/404'); });
the value of '$something'
not important.
shown example works 1 segment, i.e. 'site/foo'
or 'admin/foo'
. if request 'site/foo/bar'
or 'admin/foo/bar'
laravel throw default 404 error.
app::missing(function($exception){ return '404: page not found'; });
i tried find in laravel4 documentation nothing right me. please :)
thank you!
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 view, can find $something
{{ request::path(); }}
or {{ request::segment(); }}
Comments
Post a Comment