We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 31337
    • 258 Posts
    I really like the feature that allows you to redirect a user to a specified page when an error happens. The problem though is that this error does not get recorded in my Apache logs as a 404 error. It simply shows up as a 302 Redirect. This basically makes my Apache error log worthless.

    Am I missing something obvious in my set up? Or is there a better way to keep track of errors in my site?

    Thanks
    • It has to do with Search Engine Friendly URLs being on, but I don’t know how to reconcile them on and having Apache error logs working.
        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
        • 31337
        • 258 Posts
        But clearly the server knows when an error happens, since it has to do the redirect. Why not solve this ploblem by having the server generate a 404 and then using Apache’s error redirection to feed th right error page? Make sense?
        • Actually, the server doesn’t know. This is because the rewrite rules intercept all requests for resources that don’t exist physically on the server and send them as a query string component to MODx’s index.php. Then MODx looks for the virtual resource within the MODx database, and if it is not found, MODx handles the error.
            • 31337
            • 258 Posts
            Which rewrite rules intercept the request? Apache’s or ModX’s? If it’s the latter, why not put some logic in ModX to generate a 404 instead of the redirect and let Apache deal with it from there?
              • 7455
              • 2,204 Posts
              Its done by modx parser I like that better then people seeing some 404 apache page what maybe could be done is that a extra logging is made for the pages that are being redirected in modx instead of apache logging
              I think that this could be done the same as modx logs all visits.
                follow me on twitter: @dimmy01
              • Quote from: vbrilon at Aug 02, 2005, 06:06 AM

                Which rewrite rules intercept the request? Apache’s or ModX’s? If it’s the latter, why not put some logic in ModX to generate a 404 instead of the redirect and let Apache deal with it from there?

                The MODx SEF URL mod_rewrite rules (defined in the .htaccess file) are processing all virtual requests. And I bet you can put a snippet on your MODx error page to generate the 404 if you want the Apache log.
                  • 31337
                  • 258 Posts
                  Quote from: OpenGeek at Aug 02, 2005, 07:09 AM

                  Quote from: vbrilon at Aug 02, 2005, 06:06 AM

                  Which rewrite rules intercept the request? Apache’s or ModX’s? If it’s the latter, why not put some logic in ModX to generate a 404 instead of the redirect and let Apache deal with it from there?

                  The MODx SEF URL mod_rewrite rules (defined in the .htaccess file) are processing all virtual requests. And I bet you can put a snippet on your MODx error page to generate the 404 if you want the Apache log.

                  Ah! I totally forgot that mod_rewrite was involved. I’ll just modify that to do the Right Thing (tm) and then logging goes back to normal. Thanks.
                    • 31337
                    • 258 Posts
                    So the solution is not quite so simple. The mod_rewrite rule simply punts on any file/dir name that’s not on the filesystem and hands it off to index.php. There’s not enough knowledge at this point to know whether this is a valid request or not.

                    But in includes/document.parser.class.inc.php, in the sendErrorPage function, we reconstruct the the original request and pass that off to our error page to deal with.

                    My contention is that we should not do this since we hijack Apache’s logging. Why not return a 404 at this point and use Apache’s ErrorDocument directive to do the dirty work?
                    • Victor, I think this is a matter of preference. Again, I believe the best solution is to force the 404 error from your error page, or not use friendly aliases. I personally prefer anyone that doesn’t get one of my pages successfully be directed to a page also delivered by MODx so I can programmatically handle the issue. This gives me all sorts of options to deal with the bad requests, including email notifications, contextual error messages, and any thing else I can dream up.