The .htaccess File
Many of the technical instructions require creating a .htaccess file on
the server. This step is relatively simple, but here's some more information.
What is a .htaccess file?
htaccess files (or "distributed configuration files") provide a way to make configuration changes on a per-directory basis. A file, containing one or more configuration directives, is placed in a particular document directory, and the directives apply to that directory, and all sub directories thereof.
Where should I put it?
When you use a .htaccess file on, the file affects the current directory and any sub directories where relevant. If you place a .htaccess file in the root directory of your web site, it will affect every directory on your web site. If you want the directives to apply to only some files, create a directory and then create the .htaccess file in that directory.
How do I make it?
If you use SSH to access your account, you can simply change to the directory where you want to create the file and type "vi .htaccess" . This assumes you have some familiarity with using the vi editor.
If you use SFTP to access your account, you can create the file locally and upload it to the proper directory using SFTP. There are some steps you should take to make sure this process goes smoothly:
- Use a pure text editor like notepad, not something like wordpad or word, to create your file
- Upload the file to the server using ASCII mode so it doesn't get corrupted.
- Windows does not permit file names that begin with a period. To get around this, create a file and save it as "htaccess". After you've uploaded the file use your SFTP program to rename it to ".htaccess" on the server.
- Make sure that all your commands in a .htaccess file are on a separate line.
- DO NOT USE the Options parameter within your .htaccess file. This parameter has been set globally on the server and cannot be specified within .htaccess files.
- Depending on your FTP client, the .htaccess file may not be visible initially. Sometimes it is treated as a hidden file. This can be confusing. Usually, there is an option in the FTP client program to show hidden files. Sometimes there is an option called "remote file mask" (or something similar) which should be set to "-la" to solve this problem. If you use WS_FTP, you can also follow these instructions.
If your site was working and you upload or create a new .htaccess file and suddenly start getting 500 Internal Server errors, make sure and check the syntax of your .htaccess file and the steps above.
More Information:
You can do a lot more with .htaccess than just setting IP restrictions and Password restrictions. To learn more, check out the
Official Documentation ,
On Line Tutorial
Updated Wednesday, 19-Dec-2007 10:27:58 EST -- webhosting@jhu.edu -- JHUniverse -- Technical Information
|