The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

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:
    10
    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. Hyflex

    Hyflex Member

    Joined:
    May 7, 2015
    Messages:
    10
    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
  3. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,723
    Likes Received:
    660
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
  4. Hyflex

    Hyflex Member

    Joined:
    May 7, 2015
    Messages:
    10
    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...
     
  5. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,723
    Likes Received:
    660
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    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.
     
Loading...

Share This Page