douyou1937 2016-03-16 15:41
浏览 273

自定义错误页面未显示

I'm doing a website using the php framework symfony and twig. I want to display a custom page for errors like 404 or 500. I saw here how to do the custom page, I have the error.html.twig in app/Resources/TwigBundle/views/Exception/error.html.twig but it does not seem to be called, I'm also using the

_errors:
    resource: "@TwigBundle/Resources/config/routing/errors.xml"
    prefix:   /_error

in routing_dev.yaml and neither in the dev nor on the live site you can see the custom or the default error page.

I've looked everywhere to find how does this page gets called but I cannot find anything so if you know how to do it, or where can I find documents about this I would be really grateful.

--I know this question mmay be seen as too broad, but I really can't find anything on google about this, any help will be good--

  • 写回答

2条回答 默认 最新

  • dongyimeng3764 2016-03-16 15:52
    关注

    The error.html.twig will be shown in production on any HTTP error (e.g. 401/ 404/ 500 etc); try it by visiting /made-up-path on your host.

    You can't check this catch all error.html.twig directly in dev AFAIK, but you can check for custom 404 error pages. What I have done is rename error.html.twig to error404.html.twig and then test this in the dev environment using /app_dev.php/_error/404.html. as described here. When it works rename back to error.html.twig.

    Remember to clear cache after any changes you expect to see in prod environment.

    It's a shame you can't test the catch-all error.html.twig.

    评论

报告相同问题?

悬赏问题

  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值