Prevent Apache custom error pages on JSON responses Prevent Apache custom error pages on JSON responses json json

Prevent Apache custom error pages on JSON responses


Here is what I use for requests with the following header:

Accept:application/json, text/javascript, */*; q=0.01 
<If "%{HTTP_ACCEPT} =~ /json/">     ProxyErrorOverride Off</If>


A simpler solution:

Keep all scripts that return json in a separate directory, such as /ajax or /api, then configure Apache like this:

ProxyErrorOverride On<Directory "/path/to/ajax/or/api">    ProxyErrorOverride Off</Directory>