apache.htaccesshttp-status-code-400errordocument

Reset/Remove ErrorDocument via htaccess


I use host that has custom ErrorDocument settings already set in their httpd.conf and I can't edit this file (I don't have access) to solve the problem directly there.

Some background: I use an API that when something isn't right I manually set a responde code and print a json as error response to use in client side. Since I am triggering a response code (400 - Bad Request in my case) it falls directly in the catch of my Ajax request.

Their configuration for a custom 400 error page is causing this issue, the response of my API never returns because i got as response their custom page.


Is it possible to remove/reset or set it to show the page that triggered the error of an already set ErrorDocument via .htaccess?


Solution

  • On server where virtual server settings cannot be modified but .htaccess is accessible, this works for me:

    ErrorDocument 401 default
    ErrorDocument 402 default
    ErrorDocument 403 default
    ErrorDocument 404 default
    ErrorDocument 500 default
    ErrorDocument 501 default
    ErrorDocument 502 default
    ErrorDocument 503 default
    ErrorDocument 504 default
    

    Put it into .htaccess and it will reset error handling pages.