This site has been archived and you can no longer log in or post new messages. For up-to-date community resources please visit ezplatform.com

eZ Community » Forums » Developer » Redirect error pages to static page
expandshrink

Redirect error pages to static page

Redirect error pages to static page

Wednesday 04 February 2015 10:20:26 am - 8 replies

Hello,

I'm using the ezpublish version 2014.07 with the symfony2 frontend stack and I want to redirect my user to a static page when he's got a 404 error.

 

This is my parameters.yml:

 parameters:
    ...
    ezpublish_legacy.mySite.module_default_layout: 'myBundle:Full:error.html.twig'

 

When a user go to :

http://www.mywebsite.com/page_not_created-1 or http://www.mywebsite.com/page_not_created-2

The same template loaded, but with 2 different urls.

 

I want to redirect my user to a static page when he’s got an error, like:

http://www.mywebsite.com/error404.html

 

It's possible to do that ?

 

Thanks a lot for your answers.

Modified on Wednesday 04 February 2015 10:38:39 am by Tapia André

Wednesday 04 February 2015 3:11:41 pm

Why do you think that 2 different urls with the same content is bad?

Considering that user get 404 http code in the response, I don't see any problem with it.

Wednesday 04 February 2015 3:18:49 pm

It's not a probem for the user but I have a varnish and I want only one page for all 404 error.

Wednesday 04 February 2015 3:24:36 pm

Don't you want Varnish to cache 404 pages?

Wednesday 04 February 2015 3:45:35 pm

Of course, but if I have only one template for all errors, it'll be faster than let eZ get the content.

Wednesday 04 February 2015 3:47:57 pm

When I have a 404 error, my Cache-control looks like:  must-revalidate, no-cache, private

 

So the page it's never store in the Varnish

   

Wednesday 04 February 2015 4:38:27 pm

I'm not sure that it is a best practice to redirect all not found pages to a single page. At least you'll not see a full list of not found pages in Google Webmaster panel or another tool.

A request to your not found page will go through 404 (non static) -> 301 -> 404 (static page). So at the end it is not clear If you'll have an advantage over current solution with dynamic and not cached 404 pages.

If you are not convinced, you can try to implement your own ExceptionListener and process NotFoundHttpException: http://symfony.com/doc/current/co...ervice_container/event_listener.html

Wednesday 04 February 2015 4:52:22 pm

Ok thanks I'll try and I'll tell you.

 

Otherwise it would change the Cache-control to make it public, and the problem will be solved.

Would you know how to change that ?

Wednesday 04 February 2015 5:32:32 pm

I have only some experience with Varnish 2. It is possible to modify resp.http.

Maybe it could help: http://blog.tenya.me/blog/2012/06/25/varnish-3-dot-x-custom-error-pages/

There are also good advices about error pages in the official Varnish docs: https://www.varnish-software.com/static/book/VCL_functions.html

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from