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 New 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 Well-Known Member
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    17,858
    Likes Received:
    35
    Trophy Points:
    48
    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 New 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 Well-Known Member
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    17,858
    Likes Received:
    35
    Trophy Points:
    48
    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 New 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 Well-Known Member
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    17,858
    Likes Received:
    35
    Trophy Points:
    48
    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 New 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 Well-Known Member
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    17,858
    Likes Received:
    35
    Trophy Points:
    48
    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 New 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 Well-Known Member
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    17,858
    Likes Received:
    35
    Trophy Points:
    48
    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 New 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 New 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:
    12,231
    Likes Received:
    39
    Trophy Points:
    48
    Location:
    Pennsylvania
    Check the permissions on the files and folders you've put in place.
     
  14. Evolvermeister

    Evolvermeister New Member

    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 New Member

    Joined:
    Nov 18, 2014
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Pescara
    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 New Member

    Joined:
    Nov 18, 2014
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Pescara
    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 Well-Known Member
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    17,858
    Likes Received:
    35
    Trophy Points:
    48
    I am happy to see you were able to determine the solution. Thank you for updating us with the outcome.
     

Share This Page