Apache default index files?

TommyWillB

Registered
First, let me apologize if this is the wrong forum for this...

I've noticed an odd thing with the way Apache is behaving... It seems to explicitly need a trailing slash at the end of a URL in order to trigger it looking for my default index page.

i.e. this generates an error:
http://tomnjeff.com/digi_pix/2002/01-07_MacWorld_San_Francisco <-- no trailing slash

... and this does not:
http://tomnjeff.com/digi_pix/2002/01-07_MacWorld_San_Francisco/ <-- trailing slash

The thing that is weird is that it does not ALWAYS have this problem... It seems to only happen once per directory... If I use the trailing slash once, then after that it seems to be optional.

So here are my questions:

1) Is this some configuration subtlety I missed
2) Should there any reason why relative (2002/01-07_MacWorld_San_Francisco) vs. root (/digi_pix/2002/01-07_MacWorld_San_Francisco) links would behave differently?
3) I can't figure out the pattern, but it seems to behave slightly differently on IE and Mozilla. I think that is because IE insists on caching the results, but I'm not sure if this could also be browser dependant?

 
After diving quickly into Apples knowledge base I found little meaningfull answers. However, one article states:

Web pages you put in your Sites folder (in your home folder) can be browsed at http://your.computer.address/~yourusername/
Use your short user name, and include the ending slash (/).

They don't mention those kind of things for nothing, but still provides you with no answer. A better search can be performed on the sites below is my guess.

Apache FAQ at http://www.apache.org/docs/misc/FAQ.html
ApacheWeek at http://www.apacheweek.com
 
No other Apache masters here?

It is really very common to code links without trailing slashes... Apache really has to be able to handle this somehow.

...right?
 
Well you could always add a "rewrite rule" to your apache config that adds the trailing slash.

 
Apache actually does handle this -- it's handled automatically by mod_dir, which is the same module which handles directory indexes.

The problem is that with a default configuration, the automatic rewriting defaults to your Rendezvous name (for example, http://192.168.0.12/~colin is translated to http://quicksilver.local/~colin/) because that's what Darwin reports as its hostname. Same problem on any other UNIX system, really -- except you'd be getting redirected to "localhost" out of the box instead of something unique to your computer.

Two ways around this.
1: Set the ServerName directive. If you've using VirtualHosts, do it individually for each vhost. If you're just running one site, set it to a valid domain host (tomnjeff.com in your case).
2: Disable the UseCanonicalName directive. (Change "UseCanonicalName On" to "UseCanonicalName Off")

Either method accomplishes the same thing -- the question is just whether or not you want Apache to do the canonicalization of self-referencing URLs.

My suggestion is just to do the ServerName bit -- it's easy, earlier in the /private/etc/httpd/httpd.conf, and that way you can still have the benefit of UseCanonicalName (and if you add VirtualHosts later, each VirtualHost will canonify properly).

Edit: Removed auto-parsed URLs.
 
Originally posted by Colin
Apache actually does handle this -- it's handled automatically by mod_dir, which is the same module which handles directory indexes....
It looks like this now:
Code:
<IfModule mod_dir.c>
    DirectoryIndex index.php index.html
</IfModule>
do I need to add a "/" at the end?

The problem is that with a default configuration, the automatic rewriting defaults to your Rendezvous name.... 1: Set the ServerName directive.
I already had that done...

...but this still does not help the trailing slash thing...

Edit: Removed auto-parsed URLs.
I don't have Server Side Includes turned on... (That's what you meant... right?)
 
Back
Top