Copied from the GSRC Infrax FAQ, originally by John Reekie

Aha! well you might ask...

Peculiarly often, this symptom is caused by a missing trailing-slash, and the cure is to put in a "trailing-slash redirect" in the right place. By "trailing-slash", I mean the slash at the end of a directory URL, like this:

        http://gigascale/infrax/faq/

Without the trailing slash, of course, the URL looks like this:

        http://gigascale/infrax/faq

Now, the server code will usually find the right directory (I hope!), but any relative URLs will be broken because the client (browser) doesn't know that the URL refers to a directory. So it will translate a URL like this

        <a href="foo.html">Foo</a>
into a URL that looks like this:
        http://gigascale/infrax/foo.html
when of course you really wanted was this:
        http://gigascale/infrax/faq/foo.html
Normally, you don't care about this because on statically served web sites Apache takes care of this for you, but here we have to do it ourselves. The code to handle trailing slashes properly looks something like this (this example is from group.php3):
            if ($url == "/$group") {
                header("Location: /$group/");
                exit();
            }

This does a match against the URL (of course you have to know what the url is _supposed_ to look to do this properly, since you explicitly have to know that the trailing slash should be present and is not), and then sends an HTML header back to the client telling it to redirect to the right URL (with the slash). Note: See the FAQ near this one about HTTP headers. Sometimes this check is buried in the code because of the need to know exactly what the URL is supposed to look like.

You can see trailing-slash redirects working simply by typing eg

        http://gigascale/infrax/faq
into your browser location field, and watching it change fairly quickly to have the slash.

The reason why this bug can suddenly appear is that all the auto-generated URLs have slashes when they should have (hm, better write another FAQ about that...), but sometime people will type URLs in by hand and so on, and then click on a link and the link won't work.

One way to fix this for pages that are checked in to version control is to create a website-specific set of redirects. See /usr/local/apache/conf/rewrite-trust.conf for a command to generate the list of redirects. Note that both /usr/local/apache/conf/extras/httpd-vhost.conf and httpd-ssl.conf need to refer to the website specific redirect page.