php - 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:
- 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
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
推荐阅读
- javascript - 试图让 JavaScript 回调以非阻塞方式工作
- python - 如何在视图中更改 Django 数据库模式?
- r - R中数据帧之间的匹配和替换
- java - 使用 Java 创建一个将 Int 转换为 String 的方法
- c# - 如何避免 MVC5 + Identity 中的会话劫持?/ 使cookie服务器端无效
- python - pythonw - 无法导入大多数(如果不是全部)站点包,甚至一些内置模块
- python - 当我输入 3 时,我得到打印 4 次的结果。你能告诉我为什么会这样吗?我是 python 新手
- python - 在类范围内导入模块的类型提示
- c++ - 如何调试 WebKit2GTK+ 扩展
- php - Nginx cors 启用 html 文件不起作用