How can i get my default 404 page to show instead of a template with no content on a closed entry?
Any time I hit the url of the closed entry, it doesn’t go to my 404, it just shows the template assigned to that entry without the channel entry content.
I do have my template setting to enable strict url’s and my default 404 template is selected.
I’ve tried variations of the recommended fixes I’ve seen when searching the issue, but nothing is working. (based on this https://docs.expressionengine.com/latest/general/404pages.html)
Without seeing your template, are you using {if no_results} {redirect="404"} {/if}
? You may also want to use require_entry
https://docs.expressionengine.com/latest/channels/entries.html#require_entry.
ExpressionEngine expects the URL to be in the form of /[template group]/[template name]/[entry title or ID]
. It parses the URL in that order. So if it finds any of that, it won’t redirect to 404. In other words, if it finds the template group based on the URL, but not the template in segment_2, then it will use the default template for that group and try to return something. If it finds the group and template, but no the title or id in segment_3, then it will return the template with whatever it can. If the exp:channel:entries
tag doesn’t return any results and there’s no if no_results
in place, then it will return no data from that tag. None of these scenarios though will result in a 404.
This is a little old, but I believe the majority if not all of this still holds true: http://www.jamessmith.co.uk/articles/expressionengine_url_schematic
Thank you both, I was able to successfully get a 404 status code. This produced another issue with my homepage (which is set as the 404) not rendering the header. I have a template embed followed by a partial.
It’s odd because the homepage (site/index) works fine on it’s own, but when it’s redirected to via 404 the embed and partial aren’t working, it just shows all content below that.
Beyond the scope of this thread, but figured I’d mention it.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.