错误404页面未在Symfony 5上的生产模式显示

发布于 2025-02-01 14:26:47 字数 765 浏览 5 评论 0原文

我正在尝试自定义404页,但它仅在开发模式下出现。当我切换到生产模式时,Symfony Exception Page将显示“ get http://127.0 。 0.1:8000/xxxxxxxx”。

我的缓存被清空了,我执行了多个命令,包括“作曲家dump-env prod”,添加了一个.env.local.php文件,我还修改了控制器,但无关。检查了几个文件,包括NotFoundHttpexception.php,httpexception.php,debug_prod.php,“ bin”文件夹中的“控制台”文件,doutes.yaml,routerlistener.php和其他文件。

这是我正在寻找的结果: 默认页面

但这是我拥有的: 例外页

我真的需要您的帮助,请提前。

这是我的路由。yaml文件

index:path: / controller:app \ controller \ defaultController :: index < / code>

I am trying to customize a 404 page but it only appears in dev mode. When I switch to production mode, the Symfony exception page is displayed with the message No route found for “GET http://127.0 .0.1:8000/xxxxxxxx”.

My cache was emptied, I performed several commands including “composer dump-env prod” which added a .env.local.php file I also modified my Controller but nothing to do. Several files were checked including NotFoundHttpException.php, HttpException.php, debug_prod.php, “console” file in “Bin” folder, routes.yaml, RouterListener.php and other files.

here is the result I am looking for:
default page

but here is what I have:
exception page

I really need your help please, thanks in advance.

here is my routes.yaml file

index: path: / controller:App\Controller\DefaultController::index

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

要走干脆点 2025-02-08 14:26:47

您的404模板本身有一个错误。删除其所有内容,并使用一些简单的文本开始。如果有效,请开始添加旧内容,直到再次破裂为止。您会知道有什么问题。

Your 404 template has itself an error. Remove all its content and start fresh with some simple text. If it works, begin adding old content until it breaks again. You'll know what is the issue.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文