Custom PHP Error Pages without redirection?

Hyflex

Member
May 7, 2015
16
0
1
London
cPanel Access Level
Reseller Owner
Hi cPanel Forums,

I have a little problem/question at the moment with custom error pages that I would like to fix/get resolved.

1) Let's say we are visiting: website.com/dashboard/
2) It loads correctly and you see the page.
3) You press F5 and suddenly are met with cpanel/apache's default error 500, which is a white page with the text server error 500 (i think)
4) Look at the URL, it still says website.com/dashboard/ yet it is showing the error page WITHOUT redirecting.

Now, if we go and set a custom error page it does NOT let us include PHP so the only option I am aware of is to redirect to a PHP page with something like OR set the ErrorDocument line in .htaccess:

Code:
[I][COLOR=#808080]<script language="javascript">
    window.location.href = "[URL]https://www.website.com/500.php[/URL]"
</script>
<meta http-equiv="refresh" content="0;url=[URL]https://www.website.com/500.php[/URL]">[/COLOR][/I]

Now, any custom error page or a error page that redirects to a PHP page will work but it will not allow us to press F5 because when we refresh website.com/dashboard/ it redirects to website.com/500.php so refreshing will just keep refreshing the error page.

I know you could say put a link on the custom error page to "refresh/retry" using javascript:history.go(-1) but that doesn't solve the problem, I still can't use refresh/retry the URL.

How can I stop it from redirecting but still show the custom error page?
 
Last edited by a moderator:

Hyflex

Member
May 7, 2015
16
0
1
London
cPanel Access Level
Reseller Owner
Hello :)

You may find the solution offered on the following thread helpful:

https://forums.cpanel.net/threads/custom-404-pages-per-site.215822/

Thank you.
Hi,

That is not what I am asking for, I am specifically asking about creating a php error page not HTML.

The pages over at: i.imgur.com/e6BlKIx.png do NOT support php code, I want to have php content in my error pages BUT I DO NOT want to redirect the person away from the page they are on, for example: website.com/mycustompage/thisisgonnaerrorout/

Using the code I gave or the code in that link you gave redirects away from the page, also setting an ErrorDocument line in .htaccess also redirects away from the page.
 
Last edited by a moderator:

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,909
2,228
463

Hyflex

Member
May 7, 2015
16
0
1
London
cPanel Access Level
Reseller Owner
There are no native features in cPanel/WHM that will automatically configure that behavior. You may also want to try reviewing some of the answers on StackOverflow that involve custom Mod_Rewrite rules. EX:

http://stackoverflow.com/questions/24080919/display-custom-404-error-page-without-redirection-in-php

Thank you.
Hi,

That's specific to people going to specific pages and then throwing the custom php 404 page, mine is similar but as as I am aware you can't make a rewriterule to detect the errorpage...
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,909
2,228
463
You may want to consult with a qualified system administrator, or post to the StackOverflow forums if you do not generate additional user-feedback to this thread. Also, you can open a feature request for a native option that allows for this behavior at:

Submit A Feature Request

Thank you.