I am trying to make my web server have customized error documents/pages but with PHP
code included in them, without redirecting them away from the page that has thrown the error.
Let's say we are navigating to http://website.com/pages/1
and it was to throw the error 500, by default the page would just be a blank white page with the text "Error 500 (Internal Server Error)
" which would look something like:
As you can see from the above, it has NOT redirected away from the page that has thrown the error. I want this page to look "a part of the website" but with PHP content included in them.
I cannot include PHP content in the error pages over in the cPanel by editing the pages you see below:
If I was to edit the error 500 page above, with the content below the problem would be that http://website.com/pages/1
would redirect to http://website.com/500.shtml
and then in turn redirect to http://website.com/500.php
I do NOT want it to redirect at all otherwise it means refreshing the page essentially will just refresh the 500.php page rather than refreshing the /pages/1
<script language="javascript">
window.location.href = "http://www.website.com/500.php"
</script>
<meta http-equiv="refresh" content="0;URL='http://website.com/500.php'" />
The same exact problem would exist, just without it being 2 chain redirects instead it would just be 1 redirect using the following in the .htaccess file
ErrorDocument 400 http://website.com/400.php
ErrorDocument 401 http://website.com/401.php
ErrorDocument 403 http://website.com/403.php
ErrorDocument 404 http://website.com/404.php
ErrorDocument 500 http://website.com/500.php
Current Result: Redirecting to /500.php
Expected Result: Displaying 500.php in/on http://website.com/pages/1 without redirect
How can I have custom error pages WITH php content WITHOUT making it redirect away from the page that has thrown the error?
Is there a way to do it via root (could I get my hosts to do something, if so what?)