It appears that when using the recommended method of {if no_results}{redirect=404}{/if} in a template that uses the template layout feature, it duplicates the layout, if a layout is also used on the actual 404 template. The 404 template lives at errors/404 it includes the following:

errors/404 template

404 Error Content Here

When viewing a normal page that 404s (sitename.com/pagedoesntexist) it works as expected.

_layouts/master template


On instances that do not work as expected it's set up like the following:

Sample template using the 404 redirect tag

   Content Here

   {if no_results}

This results in the file rendering the master layout twice (double header + footer in my instance) because the {redirect=404} tag is essentially copying the results of the /errors/404 template into the template that contains no results instead of displaying the 404 page as usual.

Is there a way around this bug, preferably that doesn't require enabling php in templates?

1 Answer 1


This is a known bug in EE 2.9.0: https://support.ellislab.com/bugs/detail/20471/site-index-template-is-rendered-after-the-404-template

The fix from that thread:

Open system/expressionengine/libraries/Template.php and find this code on line 2236:

ee()->output->out_type = "404";

And REPLACE it with this:

ee()->output->out_type = "404";

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.