Thursday, July 21, 2005

Apache Problem

I'm reviving my blog on my home box. I'm using Blosxom, which throws index.html files into subdirectories of the main blog. I'm using Apache, which you can tell to look for index.html if the client requests a directory. So far, so good.

I set it all up at home. My server's machine name is 'moose'. (You'll see why this matters in a moment.) I test it out; it all works. I go to work, and try it out. The main page works, but when I click on a subdir link, it pulls up a different page, namely that of What the heck?!

Okay, right away I notice the moose connection. When I put 'moose' into Firefox's URL, it does an autocomplete thing, and I'm guessing that some DNS magic sends such a term to But why does such a thing happen?

I search my access_log, and find that any request for a plain directory (i.e. "/foodir") returns a 301. A 301 is a redirect. Seems that Apache was redirecting to a directory with a trailing slash (i.e. "/foodir/"), which would then match its pattern for trying the default index (index.html, in my case). Only it was sending back a full URL, in my case "http://moose/foodir/".

I looked around a bit, and found that apache2.conf had a ServerName directive that was set to "moose", and when I changed it to reflect the real server name, things worked.

I'm guessing that there should be a way (perhaps with mod_rewrite?) to not require a 301 return and subsequent 2nd page request for this to work, but that'll have to wait until I convert my blog.


Post a Comment

<< Home