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.

global 404 error page. Is it possible??

Discussion in 'General Discussion' started by bsasninja, Aug 27, 2007.

  1. bsasninja

    bsasninja Well-Known Member

    Joined:
    Sep 2, 2004
    Messages:
    528
    Likes Received:
    0
    Trophy Points:
    16
    I found that error_log file is enormous cause lot of sites that have broken links.

    Is there a way to show a 404 custom error page instead of default apache 404 error, to avoid error loging.
     
  2. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Note that a custom 404 error page will not prevent the 404 messages from being logged.
     
  3. velda

    velda Well-Known Member

    Joined:
    Aug 24, 2005
    Messages:
    54
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Utah
    I'm actually wondering if there's a way to do global error documents but still allow users to show their own error pages if they've got them. i'm OK with them showing up in the error log ;-)
     
  4. viraj

    viraj Well-Known Member

    Joined:
    Sep 28, 2006
    Messages:
    209
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    India
    cPanel Access Level:
    DataCenter Provider
    Twitter:
    Hi,

    Yes, this is possible, make the following changes into your server's httpd config file :

    1) Edit the apache configuration file : vi /usr/local/apache/conf/httpd.conf
    2) Search for "ErrorDocument 404 /404.shtml"
    3) Change the last part [/404.shtml] to whatever page you want the 404 to be set to for example:
    "ErrorDocument 404 http://domain.com/my404.html"
    or
    "ErrorDocument 404 /home/CustErr/404.html"

    4) Save the file & exit.
    5) Restart the apache server/service [service httpd restart].
    6) You are done :D
     
  5. mahinder

    mahinder Well-Known Member

    Joined:
    Jun 12, 2003
    Messages:
    68
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    matrix
    i tried changing custom 404 page in httpd.conf but its not changing server any idea what i may be doing wrong?
     
  6. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    You may wish to read our documentation on this: http://www.cpanel.net/support/docs/ea/ea3/customdirectives.html

    If you are only doing this on 1 or 2 websites on an entire server, a .htaccess directive may be a simpler solution.
     
  7. blaster701

    blaster701 Member

    Joined:
    Mar 16, 2006
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    1
    Apache2 global errordocument

    Hi there

    After updating apache 1.x to 2.x, global errordocument (that is, for every 40x error found in anydomain hosted) doesn't work, as apache looks for a folder within public_html of that particular domain.

    It previously worked with this directive in httpd.conf
    Code:
    ErrorDocument 404 /mycustomfolder/404.shtml
    That redirected any 404 to /usr/local/apache/mycustomfolder/404.shtml, except for domains with custom .htaccess

    However, now any virtualhost tries to look for "mycustomfolder" under public_html, not the original server DocumentRoot.

    New template system for apache 2 is a bit confusing, though i've modified several files such as post_virtualhost_global.conf

    I've installed suphp&susohin, not sure if related.

    Is it possible to configure ErrorDocument server wide?, or: if using .htaccess, where to place it?

    Any help is appreciated
     
  8. blaster701

    blaster701 Member

    Joined:
    Mar 16, 2006
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    1
    Solved!

    I knew I missed something... a line of code lost in httpd.conf and unintentionally commented

    Just insert this in httpd.conf (okey, or use WHM post-pre-template editor)

    It works for every hosted domain in your cpanel server, unless they've got custom error pages by using .htaccess. The path "/usr/local/apache/errorfolder" is enterely optional. You place your server-wide custom error SHTML pages wherever you want.

    I feel ashamed, it was so cheap... :)
     
  9. lloyd_tennison

    lloyd_tennison Well-Known Member

    Joined:
    Mar 12, 2004
    Messages:
    698
    Likes Received:
    1
    Trophy Points:
    18
    http://www.cplicensing.net/scripts.php has a script called fix404errors. The only problem with it is that it does not do subdomains.

    Since it creates the file, those errors do not get logged as they are no longer errors.
     
    #9 lloyd_tennison, Jun 19, 2008
    Last edited: Jun 19, 2008
Loading...

Share This Page