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.

cPanel/WHM custom 403 page for all accounts?

Discussion in 'General Discussion' started by enjoylife, May 10, 2011.

  1. enjoylife

    enjoylife Member

    Joined:
    May 9, 2011
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    1
    how to custom 403,404,500 page for all accounts?i want to do it on server wide by cPanel/WHM. i want to do it on server side, to all the accounts on the server not a single user. thank you.
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    27,673
    Likes Received:
    420
    Trophy Points:
    83
    cPanel Access Level:
    Root Administrator
    Hello :)

    This can be achieved by creating an alias for "/errorfolder" in the /usr/local/apache/conf/httpd.conf file via the following steps:

    1) Create a directory in /usr/local/apache to store your custom error messages. In this case, I have named the directory "customerror":

    Code:
    mkdir /usr/local/apache/customerror
    2) Ensure your custom error pages have been added to this directory (400.shtml, 404.shtml, etc).

    3) In Web Host Manager, browse to:

    "WHM Main >> Service Configuration >> Apache Configuration >> Include Editor"

    4) Select "All Versions" under "Pre Virtual Host Include".

    5) Add the following to the text box:

    Code:
    Alias /errorfolder /usr/local/apache/customerror/
    ErrorDocument 400 /errorfolder/400.shtml
    ErrorDocument 401 /errorfolder/401.shtml
    ErrorDocument 403 /errorfolder/403.shtml
    ErrorDocument 404 /errorfolder/404.shtml
    ErrorDocument 500 /errorfolder/500.shtml 
    6) Click "Update", and then click "Restart Apache".

    Your custom error pages will now be used by default.

    Thank you :)
     
  3. enjoylife

    enjoylife Member

    Joined:
    May 9, 2011
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    1
    1) Create a directory in /usr/local/apache to store your custom error messages. In this case, I have named the directory "customerror":
    how to do this? and how to upload the error pages which created by me to the customerror file?

    if the user want to overrite the error pages? could he overrite those error pages by his cpanel or .hactess. many thanks.
     
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    27,673
    Likes Received:
    420
    Trophy Points:
    83
    cPanel Access Level:
    Root Administrator
    Hello :)

    Assuming you have root access to the server, this can be done via the command line using the command provided in my last response:

    Code:
    mkdir /usr/local/apache/customerror
    More information on accessing your server via SSH can be found at:

    SSH/Shell Access

    The easiest method to create the files within this directory would likely be to create them through a command line text editor:

    Code:
    vi /usr/local/apache/customerror/404.shtml
    If you are not familiar with using "vi", feel free to use the text editor of your choice (e.g. nano or pico)

    Yes, this can be achieved via "cPanel -- Advanced - Error Pages":

    Error Pages

    Thank you.
     
  5. enjoylife

    enjoylife Member

    Joined:
    May 9, 2011
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    1
    many thanks,cPanelMichael . you made me know a lot. if i want to add some css and image in the 404.shtml. where should i put the image in, and how to upload the images which will be used on the 404.shtml?

    i am sorry i am a newbie. can i write the css code in vi for the 404.shtml.

    could i name it to 404.html not 404.shtml?
     
  6. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    27,673
    Likes Received:
    420
    Trophy Points:
    83
    cPanel Access Level:
    Root Administrator
    Hello :)

    You can simply create an images directory within your error log directory. EX:

    Code:
    mkdir /usr/local/apache/customerror/images
    You can upload the images via SFTP/SCP, or upload them to an account via FTP and move them to the directory through the command line using the "mv" command.

    You can insert or edit CSS code into the error page using "vi" if you prefer, yes. If you want to name it 404.html, remember to update the entry used during steps 3-5 from my initial reply to:

    Code:
    ErrorDocument 404 /errorfolder/404.html
    Thank you.
     
  7. enjoylife

    enjoylife Member

    Joined:
    May 9, 2011
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    1
    i have created the images according to the code which you told me. when i used the FileZilla Client tool with user root and whose password via SFTP to upload the images. i didn't find the images file that i created in vi. i see some files eg:root->csf/public_ftp/cpanel3-skel...and so on. how could i can find the images file.
     
  8. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    27,673
    Likes Received:
    420
    Trophy Points:
    83
    cPanel Access Level:
    Root Administrator
    Hello :)

    The images would be located in the directory you uploaded them to. You can not edit or create an image using a text editor such as "vi". You have to upload them to the directory, which if you used the example provided would be:

    /usr/local/apache/customerror/images

    Thank you.
     
  9. enjoylife

    enjoylife Member

    Joined:
    May 9, 2011
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    1
    i am sorry, but when i access my WHM via SFTP with root, i can't find this directory
    Code:
    /usr/local/apache/customerror/images
    the directoy i found like this:
    i can't find the customerror/images file, so i don't know where should i upload my images to and how in vi to invoke it.eg:

    Code:
    <img src="">  
    background:url(".....")...;
    
    how to write the image path and the background image path?
     
  10. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    27,673
    Likes Received:
    420
    Trophy Points:
    83
    cPanel Access Level:
    Root Administrator
    Hello :)

    You mentioned using FileZilla. In Filezilla, where it lists "Remote Site" on the right hand side, you can manually enter a directory such as:

    /usr/local/apache

    As for coding the page using HTML, the following URL should be useful for that:

    HTML Tutorial

    Thank you.
     
  11. enjoylife

    enjoylife Member

    Joined:
    May 9, 2011
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    1
    got it. i find i don't necessary to code it.i can upload the file to customerror file directory. many many thanks!
     
  12. enjoylife

    enjoylife Member

    Joined:
    May 9, 2011
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    1
    oh,damn it. the directory is as this:
    Code:
    /usr/local/apache/customerror/images
    /usr/local/apache/customerror/404.shtml
    style.css
    the 404 page can' invoke the image and style.css. why? when i access a user's site which is on my server and doesn't overwrite the 404 page. the 404 page show no style and images,
     
  13. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    13,882
    Likes Received:
    141
    Trophy Points:
    63
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:
    Check the permissions on the files and folders you've put in place.
     
  14. Evolvermeister

    Joined:
    Jan 28, 2011
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Gomel, Belarus
    Hello,

    Custom error pages applied to every user account. But how to allow users to make their own error pages in this case? I'd like my error pages to be defined only for accounts who didn't make such pages.

    Thanks for reply on advance.
     
  15. leonep

    leonep Active Member

    Joined:
    Nov 18, 2014
    Messages:
    44
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Pescara
    cPanel Access Level:
    Root Administrator
    nice post !!
    i followed instructions provided by micheal and it's ok.
    All users have default error documents pages. But it's possible to manual modify .htaccess for 1 user that want a custom error doc page ? thanks
     
  16. leonep

    leonep Active Member

    Joined:
    Nov 18, 2014
    Messages:
    44
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Pescara
    cPanel Access Level:
    Root Administrator
    does not matter
    with allowoverride option in apache conf it's possible to edit .htaccess and add following
    ErrorDocument 404 /new404.html

    thanks
     
  17. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    27,673
    Likes Received:
    420
    Trophy Points:
    83
    cPanel Access Level:
    Root Administrator
    I am happy to see you were able to determine the solution. Thank you for updating us with the outcome.
     
  18. system-error

    system-error Member

    Joined:
    Dec 16, 2014
    Messages:
    21
    Likes Received:
    1
    Trophy Points:
    3
    cPanel Access Level:
    Root Administrator
    I followed all the steps and everything seems fine, but is there a way I can actually test this to see if the page loads correctly? I want to make sure the page works fine online before it *really* is necessary.
     
  19. system-error

    system-error Member

    Joined:
    Dec 16, 2014
    Messages:
    21
    Likes Received:
    1
    Trophy Points:
    3
    cPanel Access Level:
    Root Administrator
    OK, I was trying to create an Error 508, which only happens in specific situationa. Instead I made a 404 page and I can test that by just entering an incorrect directory. :) So I solved howe to test it.

    But, I now have another issue... I am embedding an image into the .shtml or .html but the images are not showing... The paths appear incorrect. For example, if I visit domain.com/xxxx.html, the page loads fine but images within xxxx.html that are in /images/ are instead pointing to the domain.com/images/ directory.....

    So how can I make the customerror/images/ dir deliver the images?
     
  20. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    27,673
    Likes Received:
    420
    Trophy Points:
    83
    cPanel Access Level:
    Root Administrator
    You will have to use the full path to the image in your script instead of the soft path (e.g. /home/$username/public_html/images/file.jpg instead of images/file.jpg).

    Thank you.
     
Loading...

Share This Page