Main Page / Browse Categories / Howto's & Guides / Htaccess / Understanding htaccess
Understanding htaccess
Htaccess is simply nothing more than a ASCII (text) file. A text file can be created in various text editors, including notepad. Some people are confused by the name of this file, so allow me to explain:

.htaccess is the file extension. It is not file.htaccess or somepage.htaccess, it is simply named .htaccess

Disclaimer: If you are using FrontPage Extensions, there is already a htaccess file in your httpdoc folder that was created by FrontPage. Editing this file should only be done at your own risk. Also, do not remove the htaccess file and replace it with your own, as your site will not work afterwards.

If you do choose to edit the htaccess file, download it from the server first and than add in your code. Please make a backup copy of the unedited htaccess file prior to adding any code.
 
Creating an htaccess File

Open a text editor (such as notepad, not Word or WordPad) and save an empty page as htaccess (an extension of txt will be appended). The file will need to be renamed to .htaccess, but we'll leave that till after it's on the server.

Uploading an htaccess File

An htaccess file should be uploaded in ASCII mode, as it's an ASCII file (Do not use binary). The file will automatically be set to CHMOD 644 or RW-R--R--. This make the file usable by the server, but prevents it from being changed via a browser. The file is still web readable and should left that way.

Background Information

Most commands placed inside of an htaccess file are meant to be place on one line only. If you are using a text editor that uses word-wrap, make sure it is disabled. If it is not disabled, it might throw in a few characters that will annoy Apache, even though it's very forgiving of malformed content in an htaccess file.

Whats Affected

htaccess files affect not only the directory they are placed in, but also all subdirectories. For example, if an htaccess file is placed in your root directory (yoursite.com), it would also affect anything in subdirectories such as:

yoursite.com/subdirectory
yoursite.com/subdirectory/subdirectory

You can override this by placing a separate htaccess file in the subdirectories you don't want to be affected. In short, the nearest htaccess file to the content directory is treated as the htaccess file. If the nearest htaccess file is the global htaccess (located in your root folder), than it affects every single directory in your entire site.

Note: Before you start placing htaccess files everywhere, read through the tutorials here first. This will relieve you from hours of stress, caused by creating infinite loop of redirects or errors, by placing something weird in the htaccess file.



User Comments
Understanding htaccess
Add Comment
There are no user comments for this topic.
Add Comment
Additional Info
General Information
Article No. 190
Created: 04:30 AM 12.26.03
Author: HPU Support

Attachments
No attachments.

Did this help you?
Yes No

Statistics
Yes646 (53%) Voted Yes575 (47%) Voted NoNo

Other Options
Print Article
Email Article

Related Articles
Custom Errors
Deny/Block Users
Password Protection