简体   繁体   中英

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:
  • admin -- auth -- client -- user
  • common
  • front -- auth -- home

How can I add error pages only for my admins?

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
eg 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 eg can be:

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

// your custom template here 
@endif

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM