Results 1 to 2 of 2

Thread: Redirect 404 Page

  1. #1
    Registered User
    Join Date
    Apr 2011
    Posts
    4

    Default Redirect 404 Page

    Dear All,

    I know I can edit a 404 Page, but what I need to do is to be able to change what page is actually called when a 404 happens. I want to be able to call something besides 404.shtml (or whatever the real name is). I want to be able to call another page that is a script that will run when a 404 happens.

    How / where can I change this at the Vhost level?

    Thank you,

    Jeff Collins
    Nerd Boy Inc

  2. #2
    Registered Member cPanel Partner NOC Badge
    Join Date
    Jan 2009
    Posts
    8
    cPanel/WHM Access Level

    DataCenter Provider

    Default Re: Redirect 404 Page

    Hi Jeff Collins,
    ErrorDocument Directive is comes in Apache core module. You can add an ErrorDocument handler that specifies the exact numeric code and the name of the file to serve up (or CGI script to run) when that error is encountered in apache configuration file or .htaccess file.
    Here's how that might well look:

    ErrorDocument 3DigitErrorCode /path/to/your/error/file/or/script

    The 3-Digits error codes are as follows:
    Error 400 Bad Request
    Error 401 Authorization Required
    Error 403 Forbidden
    Error 404 Missing
    Error 500 Server Configuration Error

    Thus the following line tells the server to run the error404.cgi script if the server cannot find the requested page.

    ErrorDocument 404 /cgi-bin/error404.cgi

    This way, you can trap as many errors as you want.

    Below is an example of a .htaccess file, just copy and paste into your file, but change the paths:

    ErrorDocument 404 /path/to/your/error/file/or/script
    ErrorDocument 500 /path/to/your/error/file/or/script
    ErrorDocument 403 /path/to/your/error/file/or/script

    Additionally, the special value default can be used to specify Apache's simple hardcoded message. While not required under normal circumstances, default will restore Apache's simple hardcoded message for configurations that would otherwise inherit an existing ErrorDocument.

    ErrorDocument 404 /cgi-bin/bad_urls.pl

    <Directory /web/docs>
    ErrorDocument 404 default
    </Directory>
    Regards
    Alex Parker
    eUKHOST Dedicated Hosting

Similar Threads

  1. New cpanel 404 page
    By simonpearce in forum cPanel & WHM Discussions
    Replies: 1
    Last Post: 05-30-2008, 10:32 PM
  2. 404 Error Page
    By bonnaroo in forum cPanel & WHM Discussions
    Replies: 2
    Last Post: 07-17-2007, 03:18 PM
  3. Do you know how to redirect 404 error [moved]
    By hardjoko in forum New User Questions
    Replies: 0
    Last Post: 09-07-2005, 10:57 PM
  4. Default redirect 404 for whole system
    By POLVIP in forum cPanel & WHM Discussions
    Replies: 0
    Last Post: 06-20-2004, 03:21 PM
  5. 404 error when adding custom 404 page.
    By VS-Lap in forum cPanel & WHM Discussions
    Replies: 0
    Last Post: 11-06-2002, 11:01 PM
bargain