0

I have tried as documentation says:

app/
└─ Resources/
   └─ TwigBundle/
      └─ views/
         └─ Exception/
            ├─ error404.html.twig
            ├─ error403.html.twig
            ├─ error.html.twig      # All other HTML errors (including 500)
            ├─ error404.json.twig
            ├─ error403.json.twig
            └─ error.json.twig      # All other JSON errors (including 500)

But none of those shows the custom page on prod env. Then I tried to add in the same Exception folder a exception.html.twig file and it work for all the errors (404, 500, ...), but it shows it in dev, so I can't see the error when developing if I have that file. And inside the production env it shows always the red screen

enter image description here

So what's the proper way to make a custom error page to production and how to test it?

2

2 Answers 2

1

Error pages are not used in development environment. During development, it shows an other error page with more debug information (which may contain information you don't want to expose public). The Symfony header bar is not showed in production by default.

To see how the error pages look like in production, try Error page previews:

# app/config/routing_dev.yml
_errors:
    resource: "@TwigBundle/Resources/config/routing/errors.xml"
    prefix:   /_error

If your production environment shows the Symfony Exception page, make sure the debug flag is set to false in app.php:

$kernel = new AppKernel('prod', false);
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks but that not answer the question. In my production server it's not showing the common 404 page, it shows the red page of symfony. Maybe the production enviroment is not aswering as production?
I've updated my question. If that doesn't help, please share some information from config_prod.yml and (if you changed something) your app.php.
0

I think the answer for your question is about clear cache.
use this command :
$php bin/console cache:clear --no-warmup --env=prod
and you will get your Error pages,
Good luck.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.