Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder Custard7A's Avatar
    Join Date
    Jul 2010
    Location
    Australia
    Posts
    286
    Thanks
    32
    Thanked 33 Times in 33 Posts

    ErrorDocument Without HTTP Response Code

    I was wondering if this is viable. Consider this format:

    ErrorDocument 400 /error.php?id=400
    ErrorDocument 401 /error.php?id=401
    ErrorDocument 403 /error.php?id=403
    ErrorDocument 404 /error.php?id=404
    ErrorDocument 500 /error.php?id=500

    Could I simply use..

    ErrorDocument * /error.php

    .. and glean the response code from the headers instead? It would open up some new dynamic options for error handling.

    P.S. I'm not sure what response codes are in the ErrorDocument scope. ErrorDocument * might be a silly idea in itself.

  • #2
    Regular Coder Custard7A's Avatar
    Join Date
    Jul 2010
    Location
    Australia
    Posts
    286
    Thanks
    32
    Thanked 33 Times in 33 Posts
    I got around to some tests today, both ErrorDocument /error.php and ErrorDocument * /error.php cause internal server errors. I don't know if there is a syntax I'm not using I just guessed at those two or if it's plain not supported. That's all I got, for curiosities' sake.

  • #3
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,638
    Thanks
    2
    Thanked 404 Times in 396 Posts
    The first option should work, but AllowOverride has to include FileInfo in the httpd.conf in order for you to be able to use ErrorDocument in the .htacess files. There is some more information in the Apache Manual page that tells you the allowed arguments you can use.

  • #4
    Regular Coder Custard7A's Avatar
    Join Date
    Jul 2010
    Location
    Australia
    Posts
    286
    Thanks
    32
    Thanked 33 Times in 33 Posts
    Thanks Inigoesdr,

    I don't have access to http.conf on my host, but I've been using ErrorDocument in the .htaccess. I assume this means it's set up to work right. I also had a look at the documentation before posting this, but it doesn't say anything about one argument that can redirect all errors.

    I'm not sure which option you refer to as the first, if you mean this..

    ErrorDocument 400 /error.php?id=400
    ErrorDocument 401 /error.php?id=401
    ErrorDocument 403 /error.php?id=403
    ErrorDocument 404 /error.php?id=404
    ErrorDocument 500 /error.php?id=500


    .. That's what I got now, it's the other statements I was interested in.

  • #5
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,483
    Thanks
    0
    Thanked 635 Times in 625 Posts
    If

    ErrorDocument * /error.php

    were to work at all then I'd expect it to also process 200, 301 and 302 - which would then cause a recursion error when displaying error.php as that would be expected to generate a 200 and thus redirect to itself over and over until exceeding recursion limits.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •