|
It is a fact of life that if you run a busy regularly-updated website you'll
also move your files about quite often. Whilst this may not pose a problem for
you initially, search engines take a while to process dead links, and during
this time you may be losing visitors who go to your old pages and get the
standard 'page not found' error. You can prevent this by customizing your error
pages, sending your visitors instead to a nice formatted webpage that politely
tells them to keep on looking using your new navigation structure.
There are two ways to do this...
Apache Configuration If you are lucky enough to
have a decent web hosting service that gives you access to Apache's
httpd.conf file, you can set up custom error messages in a matter of
moments. Just open up the file in your favourite text editor, search for
ErrorDocument 404, uncomment out the line, and add the URL to the file on
your website containing the error message. You should end up with a
line looking something like this:
ErrorDocument 404 http://www.yourdomain.com/404error.htm
Now save your changes, upload the amended file, and restart Apache. If all
goes well, you'll now be redirected to your error page if you enter in an
incorrect URL on your server. If you have IIS or any other
webserver, access your documentation for details on how you do this for your
service.
.htaccess Configuration Even if you don't have
direct access to the Apache configuration files, all is not lost. A virtually
identical effect can be achieved using local .htaccess files. Just
use your favourite text editor to create a file called .htaccess (if you use
notepad, beware it doesn't add a .txt extension onto the end) that contains the
following code:
ErrorDocument 404 http://www.yourdomain.com/404error.htm
Notice anything familiar? :) Now upload the file to the main directory of
your website, or the specific subdirectory you want to protect. Remember that
the settings in this file will affect any directory you put it into and all
subdirectories branching off from it, but not any parent directories. Also make
sure you upload this file in ASCII and not binary, and CHMOD it to 644 or you'll
run into problems. If you don't know how to CHMOD, just download a decent FTP
program like CuteFTP, right click on the
file, and select 'change file attributes' or somesuch - that does the same
(essentially it just allows the file to be readable by the server but not by any
joe public with a browser). And that it! No reset is needed,
so you should be able to see your changes immediately.
Other Configurable Errors Although 404 (page not
found) errors are by far the most common ones you will see on the internet,
there are quite a few others that can be handled using exactly the same methods
detailed above. Just in case you ever wanted to know, they are...
| Client Side Errors |
Server Side Errors |
400 Bad syntax
401 Unauthorized
402 Not Used
403 Forbidden
404 Not Found |
500 Internal Error
501 Not Implemented
502 Overloaded
503 Gateway Timeout |
- Tutorial written by Man1c M0g
|