ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

redirect="404" not redirecting ... in some cases.

October 30, 2012 9:51am

Subscribe [2]
  • #1 / Oct 30, 2012 9:51am

    tunnel7

    125 posts

    Hello.  I have a demo site and am adding some better logic for 404s than the default.  Here is my code:

    {exp:channel:entries 
         channel="pages" 
         status="open" 
         disable="categories|category_fields|member_data|pagination" 
         require_entry="yes"}
        
         
        {if no_results OR segment_3!=""}
         {redirect="404"}
        {/if}
        
        <h3>{title}</h3>
    <p>    <hr > </p>
    
    <p>    {pg-main}</p>
    
    <p>    {/exp:channel:entries}

    This code works fine until I get to segment_3 when segments 1 is legit ... instead of redirecting I get an empty template.  For example:

    http://demo.tunnel7.com/our-work/awards/asdf

    Now, if segment_1 isn’t legit, then it redirects fine:

    http://demo.tunnel7.com/our-workasdf/awards/asdf

    So I’m a bit stumped at the moment on this one.  What I want to have happen is in every scenario if segment_3 exists to redirect. 

    I am running EE2.5.3 and am also using the Structure module.

    Thanks in advance.

     

  • #2 / Oct 31, 2012 2:08pm

    Shane Eckert

    7174 posts

    Hello Tunnel7,

    Thank you for posting your question.

    There are some limitations with the way 404’s work in ExpressionEngine.

    It is important to note that there are limitations when it comes to what will trigger this “404” type Template to display. ExpressionEngine will only display the 404 Template if the requested Template Group in the URL does not exist.

    I think you are running into this. You might also check your Structure settings. Structure changes the way that ExpressionEngine works at a very fundamental level.

    You may need to play with you htaccess file to accomplish what you are looking at, but that’s going to take some major tweaking. It’s also not supported. :-(

    Is there anything else I can help with?

    Cheers,

  • #3 / Nov 02, 2012 9:19am

    tunnel7

    125 posts

    Hi Shane,

    Thanks for the reply.  I’ll hit up the folks at Structure for their thoughts as well.  Was hoping not to have to go to the htaccess level but, yes this woud be an option as well.

    Thanks for the reply!

    derek

  • #4 / Nov 06, 2012 1:27pm

    Shane Eckert

    7174 posts

    Hey there tunnel7,

    Sounds like a plan. Please let me know what you hear from the developers at Structure.

    Thank you,

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases