Return 404 not 500 when non-ajax request on ajax pages

Damn Google bot keeps breaking the site.