I'm consulting on a web site which in order to provide clean URL's uses the 404 handler to catch what would otherwise be a 404 and serve the correct content.

In case that's not clear the 404 handler is being used to do what would otherwise be done by mod_rewrite.

So :


... does not exist on somedomain.com so the 404 handler, a PHP script, is invoked, parses the URL requested and then makes an internal requests for:


The resulting content then gets sent but in doing so it reports a 404 to the user agent.

The client is interested in using Google Analytics in order to track usage of the site.

My question is will GA provide anything useful in terms of results or will the 404 being returned by the server cause GA to discard the response ?

  • 1
    In your script (404 handler) you need to explicitly send proper 200 response code if URL was successfully routed. This should override default 404 code.
    – LazyOne
    Aug 4, 2011 at 1:04
  • I'd make that an answer if I were you. Aug 4, 2011 at 14:43
  • @LazyOne - thanks for being the original responder and pointing me in the right direction. Aug 7, 2011 at 1:20

2 Answers 2


What LazyOne said. Return a 200 from the handler. Otherwise GA will report it as a Page Not Found, which is what you are telling them anyways.


Actually you don't need to do this, it's OK to return a 404. See the question about soft 404s here:.

You can return a 404 response code while serving whatever content you want.

And further down it says

your server should return a 404 if there’s nothing there to find

Sometimes the Google crawler looks for URL that are very unlikely to exist to see if you never return a 404. I suspect if you do never return a 404 they mark you down.

  • Thanks for response. I wasn't so in SEO rankings for this question as what the effect would be for Google Analytics, nevertheless it's an interesting side-effect of what the site is doing and the link you provide is very useful. Thank you. Aug 7, 2011 at 1:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.