NTS Forums

Please login or register.

Login with username, password and session length
 

News:

Welcome to the Newtek Technology Services Forum!


Author Topic: Custom 404 errors  (Read 8078 times)

Offline YIP

  • Hosting Newbie
  • *
  • Posts: 3
  • Karma: +6/-1
Custom 404 errors
« on: August 13, 2007, 11:58:33 PM »
Hello
I've written a php page to handle 404 errors, and I want it to run instead of the default "file not found" page that comes with the server as it is supplied. This particular 404.php page will be a server wide 404 error, no matter what host/page is being requested.

Here is what my httpd.conf says now, and I'm wondering what to change.  I want all the other default pages to remain as they are, and my file 404.php is in the /var/www/html/error/ directory with the others.  Also, I don't understand how the server is finding the default files, as they appear to be commented out. 

Thanks,
 YIP


Alias /error/ "/var/www/error/"

<IfModule mod_negotiation.c>
<IfModule mod_include.c>
    <Directory "/var/www/error">
        AllowOverride None
        Options IncludesNoExec
        AddOutputFilter Includes html
        AddHandler type-map var
        Order allow,deny
        Allow from all
        LanguagePriority en es de fr
        ForceLanguagePriority Prefer Fallback
    </Directory>

#    ErrorDocument 400 /error/HTTP_BAD_REQUEST.html.var
#    ErrorDocument 401 /error/HTTP_UNAUTHORIZED.html.var
#    ErrorDocument 403 /error/HTTP_FORBIDDEN.html.var
#    ErrorDocument 404 /error/HTTP_NOT_FOUND.html.var
#    ErrorDocument 405 /error/HTTP_METHOD_NOT_ALLOWED.html.var
#    ErrorDocument 408 /error/HTTP_REQUEST_TIME_OUT.html.var
#    ErrorDocument 410 /error/HTTP_GONE.html.var
#    ErrorDocument 411 /error/HTTP_LENGTH_REQUIRED.html.var
#    ErrorDocument 412 /error/HTTP_PRECONDITION_FAILED.html.var
#    ErrorDocument 413 /error/HTTP_REQUEST_ENTITY_TOO_LARGE.html.var
#    ErrorDocument 414 /error/HTTP_REQUEST_URI_TOO_LARGE.html.var
#    ErrorDocument 415 /error/HTTP_UNSUPPORTED_MEDIA_TYPE.html.var
#    ErrorDocument 500 /error/HTTP_INTERNAL_SERVER_ERROR.html.var
#    ErrorDocument 501 /error/HTTP_NOT_IMPLEMENTED.html.var
#    ErrorDocument 502 /error/HTTP_BAD_GATEWAY.html.var
#    ErrorDocument 503 /error/HTTP_SERVICE_UNAVAILABLE.html.var
#    ErrorDocument 506 /error/HTTP_VARIANT_ALSO_VARIES.html.var

</IfModule>
</IfModule>

Offline ZootSuitRyan

  • Hosting Newbie
  • *
  • Posts: 37
  • Karma: +6/-2
Re: Custom 404 errors
« Reply #1 on: August 16, 2007, 12:00:27 PM »
What you are experiencing is the default Apache error messages.  They are commented out in the configuration file to show you where the default messages are located on your machine.  If you wish to create your own error messages, for example:
Code: [Select]
<VirtualHost 127.0.0.1>
ServerName crystaltech.com
ServerAlias *.crystaltech.com
<LimitExcept>
...
</LimitExcept>
ErrorDocument 400 /page.php?name=value
ErrorDocument 403 /page.php?name=value
ErrorDocument 404 /page.php?name=value
ErrorDocument 500 /page.php?name=value
</VirtualHost>