Jon
Jon

Reputation: 8541

Redirect 404 Error To Another Directory

I am using Symfony 2 framework and I am trying to re-direct my 404 page to another folder on my website. I am wondering how would I do this?

Currently, my 404 error page is located in app/resources/TwigBundle/views/Exception/error404.html.twig. I would like my 404 page to read from src/site/StoreBundle/Resources/views/pages/error404.html.twig.

Note that I only want to re-direct my 404 page. I still want my other errors (500, 503) to remain in app/resources/TwigBundle/views/Exception/error404.html.twig.

Upvotes: 0

Views: 485

Answers (1)

Mark
Mark

Reputation: 1754

I'm not sure why you're wanting to do this so it's difficult to advise but why can't you just put an include in app/resources/TwigBundle/views/Exception/error404.html.twig which pulls in your other template? Be sure to use the correct namespace for your bundle. Something like the below should be fine (edit where appropriate).

{% include 'StoreBundle:pages:error404.html.twig' %}

Upvotes: 1

Related Questions