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.

HTTP Headers for invalid pages

November 17, 2008 2:24pm

Subscribe [2]
  • #1 / Nov 17, 2008 2:24pm

    bkuberek

    124 posts

    Just noticed that when EE throws an Error it still returns a HTTP/1.1 200 OK

    This is very bad for SEO. I was wondering if we can return a 404 or at least a 403 in cases where EE does not return a page. Even better would be the ability to display an arbitrary template.

    I thought of writing an extension, but some of this checks are made in core.system.php and exits as soon as a problem is found. I am not sure how I would be able to write an extension to output the headers before the exit() call.

    Thanks

  • #2 / Nov 17, 2008 4:11pm

    Ingmar

    29245 posts

    Please see the Strict URLs preference we have since EE 1.6.5. That should solve at least some of the issues.

  • #3 / Nov 17, 2008 4:11pm

    Lisa Wess

    20502 posts

    bkuberek - what options are you using as far as 404s in the Global Template Preferences? Also, are you removing index.php? If so, using what method?

    In short, you should be getting 404 headers. I’m going to move this up to technical support so we can get you some assistance.

  • #4 / Nov 19, 2008 3:16am

    bkuberek

    124 posts

    Thanks for the replies.

    My problem is with error pages such as:

    “Invalid URI” => core.system.php, line 142.
    “Invalid GET Data” => core.input.php line 205.
    “Error: The URL contains too many segments.” => core.input.php line 280.
    “Disallowed Key Characters” => core.input.php line 410.

    All I need is that right before the

    if ($uri != ok))
    { 
        exit('error message');
    }

    we output a http header

    if ($uri != ok))
    { 
        header("HTTP/1.1 400 Bad Request");
        // or header('HTTP/1.1 403 Forbidden');
        // or header("HTTP/1.1 404 Not Found");
        exit('error message');
    }

    this way search engines will know these are not content to be indexed.

    In addition, I have been requested that a user friendly page containing links be displayed no matter what kind of error. So it would be very nice to have an event that will be triggered for every such error that would then load a template to be outputted to the browser.

  • #5 / Nov 19, 2008 3:43am

    Ingmar

    29245 posts

    Feel free to make the appropriate feature request, please. I am not sure that these are genuine cases of “404 Page not found” errors, but I suppose a case could be made for it.

  • #6 / Nov 19, 2008 3:57am

    bkuberek

    124 posts

    I am not sure that these are genuine cases of “404 Page not found” errors, but I suppose a case could be made for it.

    In your opinion, what should such pages output in the header? I am also not 100% a 404 is the right thing but obviously not a 200 right?

    The reason I am insisting on this is because we consulted with an SEO person and we have been doing a lot of changes ever since. My client is very strict and cannot let anything slip.

  • #7 / Nov 19, 2008 4:15am

    Ingmar

    29245 posts

    I am open to arguments. “400 Bad Request” could be appropriate in a number of cases.

  • #8 / Nov 19, 2008 4:22am

    bkuberek

    124 posts

    I agree with a “400 Bad Request” for the errors I mentioned above. “404 Page Not Found” should really be used for non existing pages/content. Let me bring this up for discussion and I’ll let you know what I find out.

    Feel free to make the appropriate feature request, please.

    This was a Feature request originally but Lisa moved it over here. Should I created a new Post under Feature Requests?

  • #9 / Nov 19, 2008 11:51am

    Robin Sowell

    13255 posts

    A 400 makes sense to me, but would definitely take some thought on the implementation.  For example, instead of an exit, use the output class.  At least something to consider. 

    I think I would make a new post in feature request- I’d move this one, but think it’s a little confusing.  Just be clear on the type of errors you’re talking about- the examples are great.  That’s when I ‘got it’.

  • #10 / Nov 19, 2008 1:26pm

    Lisa Wess

    20502 posts

    Ah, I see now.  I thought you simply meant something like “not found” using the if no_results conditional - that sort of thing.  Yes, I agree with making a new feature request and I won’t move it, a 400 sounds like a great idea to me. =)

    Going to close this one off now, thank you bkuberek!

    Note: The FR is here.

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

ExpressionEngine News!

#eecms, #events, #releases