custom cPanel error files http headers
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.
-
forgot to susbcribe to get answers. Sorry! 0 -
Does this help ? Error Pages - Version 68 Documentation - cPanel Documentation 0 -
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. 0 -
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... 0 -
@rpvw thanks for update. will run some more tests! 0
Please sign in to leave a comment.
Comments
6 comments