We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Closed Entry 404 Issue

How Do I?

Torch's avatar
Torch
40 posts
3 years ago
Torch's avatar Torch

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)

       
Andy McCormick's avatar
Andy McCormick
322 posts
3 years ago
Andy McCormick's avatar Andy McCormick

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

       
Russ K.'s avatar
Russ K.
174 posts
3 years ago
Russ K.'s avatar Russ K.

I was just logging in to make the same recommendation as above. Add the following ot your template if you haven’t already:

{if no_results} {redirect="404"} {/if}

R

       
Torch's avatar
Torch
40 posts
3 years ago
Torch's avatar Torch

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.

       
HanoraSakura's avatar
HanoraSakura
1 posts
3 years ago
HanoraSakura's avatar HanoraSakura

Thanks for this thread, it’s very helpful for me 1v1 lol unblocked

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.