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.
A typical .htaccess file might look like this:
ErrorDocument 403 /forbid.html
ErrorDocument 404 /notfound.html
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 -IndexesThere are other options as well, which will be covered later.
Now you should have a file that looks similar to this:
ErrorDocument 401 /noauth.htmlOne 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.