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!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

custom cPanel error files http headers

Discussion in 'General Discussion' started by baronn, Dec 27, 2017.

  1. baronn

    baronn Member

    Joined:
    Dec 27, 2017
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    manchester
    cPanel Access Level:
    Root Administrator
    Hello everyone.

    Hoping that someone can point me in the right direction here.

    I have a vps and full root access. Running the latest version of whm/cpanel: Apache/2.4.29 - CENTOS 6.9 68.0.21

    So I updated a site to php 7.1. All working beautifully and love the increased performance over php 5.6

    I just addressed some 404 issues and on looking at my logs I saw that there were quite a few hits to domain.com/403.shtml/ which were going to 404 on my wordpress install.

    Investigating I saw that this is a custom error file from cpanel.

    Firstly I addressed why it was going to 404 as there was / in front (issue with cache plug-in which is fixed now) and also the file itself didn't exist. So I went to error pages in cpanel and saved some example text.

    once I did that it created the relevant shtml in public_html i then also updated my .htacces and added this: ErrorDocument 403 default

    I then tried a file which required access and it shows the default forbidden message and not the shtml file content I was expecting.

    I can navigate to the 403.shtml file and can see it no issues with my custom content. I know that I can also update my htaccess addition to point to this shtml file.

    However when I checked the status code of the custom 403.shtml file it shows a 200 response code?! surely that's not right? should it and how can I get it to show the correct error code?

    Is the only way to do this is create a manual file (php) and add in headers to that php file and then use that for my 403 (and other) error pages?

    I was expecting this: create custom *** error page. Update htaccess to include the location to it and voilà it works. However it wouldn't have the right header response I was expecting i.e. 403 forbidden.

    Is this a bug? or have I missed something here??

    Hope all the above makes sense and looking forward to your expert replies.

    Thanks.
     
  2. baronn

    baronn Member

    Joined:
    Dec 27, 2017
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    manchester
    cPanel Access Level:
    Root Administrator
    forgot to susbcribe to get answers. Sorry!
     
  3. rpvw

    rpvw Well-Known Member

    Joined:
    Jul 18, 2013
    Messages:
    618
    Likes Received:
    192
    Trophy Points:
    43
    Location:
    Spain
    cPanel Access Level:
    Root Administrator
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    42,715
    Likes Received:
    1,704
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    You should use the option referenced in the previous post to setup the custom page. Or, if you prefer to upload them manually, avoid adding any entries to the .htaccess file as that's not required. A similar question was asked on the following thread:

    SOLVED - default error documents.

    Thank you.
     
  5. baronn

    baronn Member

    Joined:
    Dec 27, 2017
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    manchester
    cPanel Access Level:
    Root Administrator
    thanks for the couple of replies.

    I had already read those and don't think they answer my specific question. I don't have any issues creating the error pages as discussed.

    My question relates to:

    Those custom error pages don't have the correct http headers.

    SO if I do create a 403 custom error page (i can create it and reference in htaccess for when that error occurs). it wont have the correct http header i.e. 403 forbidden BUT a 200 response http header instead.

    I would have assumed that it would automatically add the correct http header on which ever error page i customise and then i can change the 'internal' content as desired. Doesn't seem to work like that...
     
  6. rpvw

    rpvw Well-Known Member

    Joined:
    Jul 18, 2013
    Messages:
    618
    Likes Received:
    192
    Trophy Points:
    43
    Location:
    Spain
    cPanel Access Level:
    Root Administrator
    I ran tests using the Error Pages - Version 68 Documentation - cPanel Documentation instructions, and the response codes on the newly edited pages were all consistent with the returned error page. eg a Not Found page returned a 404 Not Found header response as expected.

    The relevant shtml files were edited/created in the webroot for the domain, and no entries were added to the htaccess file.
     
  7. baronn

    baronn Member

    Joined:
    Dec 27, 2017
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    manchester
    cPanel Access Level:
    Root Administrator
    @rpvw thanks for update. will run some more tests!
     
Loading...

Share This Page