#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2012
    Posts
    13
    Rep Power
    0

    Designing my own error 404 - page not found


    hi Guys,

    when i type incorrect url in my browser, i want apache to redirect to my own 404 error page - page not found

    this is the line of code in the httpd.conf file i edited

    ErrorDocument 404 errors/FileNotFound.html

    But it doesnt work

    I even created a .htaccess and insert the same line of code, but still its not working,can some please assist
  2. #2
  3. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,238
    Rep Power
    9400
    It's easier in the .htaccess, not the httpd.conf.

    In that httpd.conf, or in the definition for your VirtualHost, did you enable AllowOverride? Also, post the definition of your site (either the VirtualHost or the default) and the contents of the .htaccess.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2012
    Posts
    13
    Rep Power
    0
    Originally Posted by requinix
    It's easier in the .htaccess, not the httpd.conf.

    In that httpd.conf, or in the definition for your VirtualHost, did you enable AllowOverride? Also, post the definition of your site (either the VirtualHost or the default) and the contents of the .htaccess.
    Thanks for replying
    I am not 100% sure where the .htaccess file should go, i tried several places still not working.

    i have just set the allowOverride to ALL - Still not working

    This is the content of my .htaccess file
    ErrorDocument 404 errors/filenotfound.php


    Not sure about your other question regarding virtualhost
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2012
    Posts
    12
    Rep Power
    0
    What error message do you get when you point the browser to a file that does not exist? Does it contain a line like:

    'A 404 error was found when trying to use an ErrorDocument do handle the request.'

    If this is not there, then the server may not be interpreting your directives. Remember you need to restart the server every time to edit httpd.conf.

    If it is there, try changing the directive to
    ErrorDocument 404 /errors/filenotfound.php

    The first slash tells the server to look from the ServerRoot directory for the file, instead of in the non-existent directory. With your current directive, if you request the page "/foo/bar/index.php", the server will look look for /foo/bar/errors/filenotfound.php which obviously doesn't exist. Changing the ErrorDocument to above will make the server look in "/errors/filenotfound.php" which is what you want.

    Hope that helps.

IMN logo majestic logo threadwatch logo seochat tools logo