We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21257 MODX Staff
    • 730 Posts
    ndh611,

    It might help to get specific about the http responses in question. (I'm not sure what "hard redirect", "hard 404", "soft 404" really mean.)

    MODX's "Not Found" response does output the 404 HTTP Response code, so I can't imagine why you would want to do some sort of redirect (301? 302?) to some other page that also outputs the 404 HTTP Response code. There's no real difference HTTP-wise if MODX is creating the Not Found response vs. some page generated at the http server level. I'm no authority on HTTP Response Codes and SEO however, so I'd be happy to understand the challenges and details better if you have some extra information.

    In any case, it is possible to intercept the Not Found event in a Plugin - no need to hack the core. The event your plugin should listen to is OnPageNotFound.

      Mike Schell
      Lead Developer, MODX Cloud
      Email: [email protected]
      GitHub: https://github.com/netProphET/
      Twitter: @mkschell
      • 22303 MODX Staff
      • 10,725 Posts
      If you hard redirect, you are telling Google that your 404 page is an actual valid URL with a 200 response. I don't think the SEO guy knows what he's talking about.
        • 21061
        • 10 Posts
        Thanks guy for your answer. I will get back to this SEO guy with your answer. Yours sounds much more valid than him.
          Coffeemug - simple & effective web solutions
          http://coffeemugvn.com
          • 9065 ☆ A M B ☆
          • 15 Posts
          I've found one intresting detail about MODX:
          Any nonexistent page returns php header 404, but the exact URI of error_page 404 MODX resource returns code: 200 OK. You can test it by yourself with http://www.bertal.ru/

          It means, if you do hard redirect to 404 page in MODX you'll have such queue of headers:
          HTTP/1.1 301 Moved Permanently (or HTTP/1.1 302 Moved Temporary)
          Location: /error_page/
          HTTP/1.1 200 OK


          Thats very bad for SEO.

          So... I solved it this way:
          1) Created new template "404" for pages always hard redirect to 404

          2) Created snippet "generate404" with code
          $uri404='/404/'; // NONEXISTENT PAGE URI
          if($_SERVER['REQUEST_URI'] != $uri404) header("Location: $uri404", TRUE, 301);
          


          3) put the [[!generate404]] call in begining of my new template "404"

          Result:
          HTTP/1.1 301 Moved Permanently
          Location: /404/
          HTTP/1.1 404 Not Found


          Not very beautiful, but it works...