Custom 404 Page
Personalize Your Site With A
Customized 404 Page
For a more personal and professional look to your web site, create a
custom 404 "Page Not Found". A custom 404 page can present your users with more
options than just clicking the browser’s BACK button. You can easily add
links to your major section, popular pages, and even a link to a site
problem report form.
What You Will Need:
In order for you to override the host’s server or browser 404 error page,
you must have access to either an .htaccess or the srm.conf
file on your apache server. If you’re on a Window server, things can get
much more complicated. If you are unsure as to which file to use, it may
already be solved for you by your host. Most hosts will only allow access
to the .htaccess file but they may not be willing to help you
modify the file or they may say they don’t support custom 404 pages. This
is usually to protect themselves so if you mess up your web site, they
aren’t at fault. For more details on modifying an .htaccess file, I have
included several links at the end of this article.
Modifying The .htaccess File:
To modify the .htaccess file, first check to see if you already have one
in your web’s root directory. If so, use your FTP program to download a
copy to your computer. Open the file in a text editor (Notepad works)
and see what is in it. The file could be blank or if you’re using
FrontPage extensions, it will have several lines of information. DO NOT
EDIT ANY EXISTING FILE INFORMATION!!
Add this line as the first line of the file:
Error Document 404/file.ext
File.ext should be your name for your 404 page. A simple name like
404.html is best or something like notfound.html. You can also place the
custom 404 page in a directory:
Error Document 404/directory/file.ext
Once the file is modified, save it to your computer. Upload this file
to the root director of the web site where you got the file.
NOTE:
If the file has data, that file can only be used on the web site from
which you downloaded it; otherwise, the file can cause an .htaccess
intrusion error on some Internet security programs. Also it could mess up
your FrontPage operation if the web address is from another FrontPage
site.
404 Page Links:
I recommend that you use absolute paths for all links on the custom
404 page. Relative links only appear to work if the error is generate when
coming into the site. If you are looking at a page that is in a directory
other than the root directory, relative links get broken because the page
is called by the server reading the .htaccess file. For this reason,
absolute paths work from any region of your site.
Absolute Path:
http://www.yourdomainname/directory/file.ext
Relative Path:
../directory/file.ext
Helpful Links:
http://www.javascriptkit.com/howto/htaccess1.shtml
http://www.bignosebird.com/apache/a7.shtml
The bignosebird site also provides information for 404 pages on Window's
servers.
|