Things look quiet here. But I've been doing a lot of blogging at
dan.langille.org because I prefer WordPress now.
Not all my posts there are FreeBSD related.
I am in the midst of migrating The FreeBSD Diary over to WordPress
(and you can read about that here).
Once the migration is completed, I'll move the FreeBSD posts into the
new FreeBSD Diary website.
404 - what to do about missing www documents16 January 2000
This article discusses how I dealt with missing articles when I moved my
websites around. It allows you to display a custom page depending on the situation.
This is only a simple solution. You can get complex with CGI code, but that
wasn't an option I wished to pursue.
Until recently, my website was shared by four domains (see Not much new here. What's going on? for
details). I decided that it was time to give each domain it's own website.
Until recently, I could not afford to run separate websites for each domain.
up the mega-website into found separate websites was easy, but very time consuming.
But the resulting changes to URLs and file locations meant that people who had bookmarks
and the data in the search engines would all be wrong. For example, you could have
seen the racing system stuff by using:
But after the split, only the following URL would work:
Similarly, the FreeBSD Diary URLs ended with /freebsd/, the PowerBuilder tips ended
with /pbtips/, and the free web space ended with /freespace/. I wanted to ensure
that appropriate messages where given no matter what URL you were looking for.
The working solutions
In this section, you'll see working examples of the above strategy.
In the following section you'll see how I did this.
If you go to the missing page
you will see the page which is displayed whenever a URL request cannot be satisfied.
This is a missing document. If you try this fake URL
that page will be displayed.
To create a default error page, you need to use the ErrorDocument
directive. Here is what I added to /usr/local/etc/apache/httpd.conf:
ErrorDocument 404 /missing.php
For more information on the ErrorDocument feature, please see the Apache documentation.
For a complete virtual host example, see the following
section. You may or may not need the AllowOverride. This directive ensures
that the ErrorDocument directive can be used (see the Apache documentation for more info).
The above bit of code tells Apache that if any 404 errors (document not found) are
generated in the indicated directory, the the page /missing.php should be
displayed. You can see that file at this URL testing404.txt.
This is quite a simple solution. I'm sure you can get quick complex if you want.
Order is important
The order of your ErrorDocument directives is important. If you put
the directive for "/www/freebsddiary.com" before the directive for
"/www/freebsddiary.com/testing/pbtips", then the latter will never be invoked.
The ErrorDocument processing takes the first match. So put your directives bottom-up
rather than top-down.
I prefer the all-in-httpd.conf example. But if you are web-hosting for other
people, you might want the .htacess solution.
Things that can go wrong
If you see this message in your browser:
500 Internal Server Error
Internal Server Error
The server encountered an internal error or misconfiguration and was
unable to complete your request.
Please contact the server administrator, firstname.lastname@example.org
and inform them of the time the error occurred, and anything you
might have done that may have caused the error.
More information about this error may be available in the server
Apache/1.3.9 Server at www.freebsddiary.com Port 80
And this in your logs:
/www/freebsddiary.com/racesys/.htaccess: ErrorDocument not allowed
It means you didn't include the AllowOverride directive in the correct place.
Check that and try again.