Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Custom PHP Error Pages without redirection?

Discussion in 'General Discussion' started by Hyflex, Aug 24, 2015.

  1. Hyflex

    Hyflex Member

    Joined:
    May 7, 2015
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    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?
     
    #1 Hyflex, Aug 24, 2015
    Last edited by a moderator: Aug 24, 2015
  2. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    44,802
    Likes Received:
    1,896
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. Hyflex

    Hyflex Member

    Joined:
    May 7, 2015
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    London
    cPanel Access Level:
    Reseller Owner
    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.
     
    #3 Hyflex, Sep 15, 2015
    Last edited by a moderator: Sep 16, 2015
  4. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    44,802
    Likes Received:
    1,896
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. Hyflex

    Hyflex Member

    Joined:
    May 7, 2015
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    London
    cPanel Access Level:
    Reseller Owner
    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...
     
  6. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    44,802
    Likes Received:
    1,896
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    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.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice