首页 > 解决方案 > How add Laravel 8 error pages 403, 404, 500, 503

问题描述

I have many routs in my project. Other for frontend and others for backend. I need add error pages 403, 404, 500, 503 for my admin.

My routs structure:

  1. Routers:

How can I add error pages only for my admins?

标签: phplaravel

解决方案


Laravel error pages are pre-packaged blade templates, you can publish and edit them according to your liking:

php artisan vendor:publish --tag=laravel-errors

Once done, you will see the error pages in resources/views/errors
e.g resources/views/errors/404.blade.php

You can then edit these templates, add conditioning for your routes/admins as well as modify the content that's shown on those pages.

One e.g can be:

@if (strpos($_SERVER['REQUEST_URI'],'admin')) 

// your custom template here 
@endif

推荐阅读