Results 1 to 2 of 2

Thread: Redirect 404 Page

  1. #1
    Registered User
    Join Date
    Apr 2011

    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
    cPanel 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/

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

Similar Threads

  1. /Webmail/ redirect leading to 404
    By ferdi2000 in forum General Discussion
    Replies: 5
    Last Post: 01-14-2015, 05:04 AM
  2. 404 Default page
    By maxihost2 in forum General Discussion
    Replies: 4
    Last Post: 11-25-2006, 05:55 AM
  3. Do you know how to redirect 404 error [moved]
    By hardjoko in forum General Discussion
    Replies: 0
    Last Post: 09-07-2005, 11:57 PM
  4. Default redirect 404 for whole system
    By POLVIP in forum General Discussion
    Replies: 0
    Last Post: 06-20-2004, 04:21 PM
  5. 404 error when adding custom 404 page.
    By VS-Lap in forum General Discussion
    Replies: 0
    Last Post: 11-07-2002, 12:01 AM