FutureQuest, Inc. FutureQuest, Inc. FutureQuest, Inc.
Using .htaccess on the FutureQuest servers
Posted on 04 December 2003 05:17 AM

Many people feel intimidated at the idea of creating and using an .htaccess file. Here we will show you how to use many of the features available in an .htaccess file.

Filename
Some text editors will not allow a filename of .htaccess. The best way around this problem is to call the file htaccess.txt first and change the name later. You can create this file in Notepad or any other text editor.

Note that in Notepad (and most other editors) when you click "Save As" and are prompted for a filename, you can enclose .htaccess in quotes and it will allow the file to be saved as .htaccess.

Format
.htaccess files contain commands that can override certain functions of a server's configuration. What can be overridden depends on the server; here we will be focusing on FutureQuest® specifics.

A typical .htaccess file might look like this:

    ErrorDocument 401 /noauth.html
    ErrorDocument 403 /forbid.html
    ErrorDocument 404 /notfound.html
    Options -Indexes
Directory Indexing
You can also use .htaccess to disable indexing, or Directory Browsing. By default, this option is turned on in the server's configuration files. To disable this, add this line to your .htaccess file:
Options -Indexes
There are other options as well, which will be covered later.

Finishing up
Now you should have a file that looks similar to this:
ErrorDocument 401 /noauth.html
ErrorDocument 403 /forbid.html
ErrorDocument 404 /notfound.html
Options -Indexes
One entry per line, and a return after the last line.

Uploading your file
Now we have an .htaccess file, or at least an htaccess.txt file, so now what? The next step is to put it on the server. This can be done in a few ways, but we will focus on FTP here.

You will need is an FTP client, like CuteFTP or WS-FTP. There are a number of FTP clients out there and this guide assumes that you already have one installed and have a basic idea of how it works.

The first thing is to make sure that there is not already an .htaccess file in the directory you will be working with. On FutureQuest®, there is a .htaccess file in your /stats directory by default. You can edit this if you like, but it may be a good idea to back it up first.

Log into your FTP account, and make sure that you are in your www directory. It should be something like /big/dom/xyourdomain/www. Once you are in there, rename or delete any existing .htaccess file. To rename, you may need to consult your FTP program's documentation. In CuteFTP and most others, you can right-click on the file and select rename or delete from the context menu.

Next is to simply upload the file to your /www directory in ASCII format (or text on Mac). Once the file is uploaded, you will need to rename it to .htaccess, if you have not already done so.

Now you should go to your site and type something like: http://www.example.com/file_that_does_not_exist (replace example.com with your actual domain name) and you should get your 404 page. Another thing to test is indexing - go to the address bar of your browser and type the name of a directory on your server that has no index file in it. For an example of this, click here. That is an existing images directory on this account, which has no index file.

If you should have questions, the FutureQuest® Community Forums would be an excellent place to inquire about this topic. Click here to visit the Community Forums now!