Skip to content

Changing the default home page on Apache server

A client I visited the other week is transferring her web site to my server in the lead up to her new site being developed. I had to make a few little mods to make the old site work on my server because the homepage file has an unconventional filename.

If you browse to a domain url without specifying a filename (eg. http://www.thewebsite.com/) the server will look for a default homepage file, which has been specified by the host in the server config settings. In most cases this default file will be called something like index.html, home.html or default.html (plus respective file extensions htm, php, cgi, shtml etc). It is a common naming convention, and several names can be listed in the config so if the server can’t find a file of one name it will look for the next in the list and so on.

This client’s homepage had been named “the_glen_home.html”. Rather than rename the file and go through the entire site modifying links I uploaded an Apache directive to serve the_glen_home.html as the default homepage. It was a simple matter of entering the following line into a text editor program (I use EditPad) and saving the file as .htaccess – note there is nothing before the dot “.”

DirectoryIndex the_glen_home.html

Then I uploaded the file, in ASCII format to my web site in the web document root. Note – it only works on Apache web servers, and be careful that you don’t overwrite an existing .htaccess file. If .htaccess file already exists, download a copy of it and add the above line to the bottom. If you Google “.htaccess” you’ll discover a ton of neat things you can do to change how your server operates.

The other thing I discovered about this site is it is a dog’s breakfast of upper case and lower case file naming, for example all the graphics files were saved in a directory named “Images” (with upper case) but some of the HTML in the web pages referenced files in an “images” (lower case) directory. This isn’t a problem on a Windows server, but on a case-sensitive Linux/Apache server the files aren’t correctly referenced and show up as errors in the browser.

It seems so sloppy not to be consistent with file naming. I’ve had lower case filenames on the brain for so long now I really look down on camel case. Same for file names with spaces!