Archive for September 14th, 2005

Small .htaccess tip

Okay, okay, I know that the ability to use .htaccess- to change the default directory page is a pretty basic trick. But this is the first time I’ve tried it. And I am quite pleased with the results.

How does it work?

Tired of having yoursite.com/index.html come up when you go to yoursite.com? Want to change it to be yoursite.com/ILikePizzaSteve.html that comes up instead? No problem!

DirectoryIndex filename.html

This would cause filename.html to be treated as your default page, or default directory page. You can also append other filenames to it. You may want to have certain directories use a script as a default page. That’s no problem too!

In my specific case, many years ago I set up my personal blog through Blogger. At the time, I didn’t know what I was doing, so I set Blogger to save this file at http://biffster.org/thoughts/blogger.html. This worked fine for a while. But then I decided that I wanted to shorten the URL for my personal blog down to just http://biffster.org/thoughts (much like this blog is http://biffster.org/computer). The problem is, after five years of keeping my blog in one spot, more than a few people have this bookmarked. And I don’t want to alienate my readers!

I’ve toyed with doing a few different things, such as creating a link from blogger.html to index.html. My hosting provider doesn’t allow this, however. I considered mirroring the two files, so a change to one would reflect in the other. But I’d have to do that locally, ftping the changes, which would introduce lag time there.

And then, as I was headed out the door from work last night, a light went off over my head. “.HTACCESS!!!” It took me less than a minute to make this change! And it works flawlessly. Screw index.html: I simply added blogger.html as the DirectoryIndex for /thoughts and *presto*!

Now don’t I feel silly for not thinking of this a long time ago!

Profile picI am a 40-ish uber-geek, Daoist and family man. Blessed to have one incredible wife and three wonderful kiddos. Dao has been kind to me.

Archives
September 2005
S M T W T F S
« Aug   Oct »
 123
45678910
11121314151617
18192021222324
252627282930  
QR Code
Top categories