在我的 Symfony2 项目中,我进入了开发模式正确的 404 异常屏幕。但是在生产模式下,我得到了带有 HTTP 状态代码 500 而不是 404 的空白屏幕。我正在使用位于app/Resources/TwigBundle/views/Exception
. 在 apache 错误日志中,它会创建以下消息:
PHP Fatal error: Uncaught exception 'Symfony\\Component\\Routing\\Exception\\ResourceNotFoundException' in /home/test/app/cache/prod/appprodUrlMatcher.php:518\nStack trace:
#0 /home/test/app/cache/prod/classes.php(1025): appprodUrlMatcher->match('/404')
#1 /home/test/app/cache/prod/classes.php(4550): Symfony\\Component\\Routing\\Router->match('/404')
#2 [internal function]: Symfony\\Bundle\\FrameworkBundle\\EventListener\\RouterListener->onKernelRequest(Object(Symfony\\Component\\HttpKernel\\Event\\GetResponseEvent))
#3 /home/test/app/cache/prod/classes.php(3777): call_user_func(Array, Object(Symfony\\Component\\HttpKernel\\Event\\GetResponseEvent))
#4 /home/test/app/cache/prod/classes.php(3703): Symfony\\Component\\EventDispatcher\\EventDispatcher->doDispatch(Array, 'kernel.request', Object(Symfony\\Component\\HttpKernel\\Event\\GetResponseEvent))
#5 /home/test/app/cache/prod/classes.php(4787): Symfony\\Component\\EventDispatcher\\EventDispatcher->dispatch('kernel.request', Object(Symfony\\Component\\HttpKernel\\Event\\Get in /home/test/app/cache/prod/classes.php on line 4560