I have a PHP script set up to do error handling so that I can integrate the error pages with the rest of my site. So I have this in my Apache config:
ErrorDocument 400 /errors.php?e=400
ErrorDocument 401 /errors.php?e=401
ErrorDocument 403 /errors.php?e=403
ErrorDocument 404 /errors.php?e=404
ErrorDocument 405 /errors.php?e=405
ErrorDocument 408 /errors.php?e=408
ErrorDocument 500 /errors.php?e=500
ErrorDocument 503 /errors.php?e=503
ErrorDocument 505 /errors.php?e=505
That catches all of the errors that occur and then dumps them over to the script. Wonderful! However it is making it difficult to use relative paths in the script because I have no clue where in my directory structure the file that generated the error would have been called from.
So the question is: Is there any way to get the URL that generated the error that called the script?
Armed with this I could count how many directories there are and put in enough "../" to get the relative directory back to the root.