HOME | GETTING STARTED | WEB HOSTING | DOMAINS | MY ACCOUNT | SUPPORT | ABOUT
       Home: Support: Manual: .htaccess:

.htaccess

The ".htaccess" file can be placed in one or many of the directories in of server. This file "controls" the access to the pages in a directory.

When your server goes to hand out a file, it starts checking in the top directory for a .htaccess file, and then checks each subdirectory down to and including the directory that your file is in. Thus you can set the defaults for your server by placing a .htaccess file in the top directory of your server, or your home directory.

For example, you can see in your Control Panel exactly how to setup customized Error Pages. This is nothing more than creating a .htaccess file to handle server errors such as the "404 File Not Found" message. You may set this up manually using a .htaccess file

Redirect all 404 not found and other errors to a page of your choosing

404 errors are generated when users try to go to a page that doesn't exist, like a typo in the url. By default, these errors cause a plain, ugly page to be shown to the user. To redirect a 404 or other error, add the .htaccess code below, substituting the url of the page you want the user to be redirected to.

Other common codes you can set up custom pages for include 401 (you need a password) 403 (you're not allowed to see this page), and 500 (a cgi script somehow didn't work right).

 ErrorDocument 404 http://www.domain.com/pagemissing.htm
 ErrorDocument 500 /errors/cgierror.htm
 ErrorDocument 401 /errors/needpassword.htm
Note the two kinds of URLs. You can use either a full URL (starting with http://) to redirect to a different site, or use just the path to display a page on your site. It is always preferable to use the second form, the local path. For redirecting 401 errors, you should always use the local path, NEVER a full URL.

Ban certain IPs from accessing your site, or only allow certain IPs

Allow only certain users from certain ISPs to access:

 <Limit GET>
 order deny,allow
 deny from all
 allow from your.isp.net
 </Limit>
Block certain users from certain ISPs:

 <Limit GET>
 order allow,deny
 allow from all
 deny from bad.people.com
 </Limit> 
Redirection

The Redirect Directive is a nice simple way to push a browser over to a different page if you've re-organized your web-site. If you moved a page in somedir from page1.htm to page2.htm then the appropriate line to add to your .htaccess file would be:

 Redirect /somedir/page1.html http://your.domain/somedir/page2.html   
After adding this code to your .htaccess file, whenever a user tries to go to page1.html, they will be redirected to page2.html; meaning, page2.html is what they'll see in their browsers.
There are a great many things you can do with .htaccess. Typically, most of the things you would need .htaccess for are implemented into the Control Panel, such as password protecting directories, assigning users, etc..

For more extensive .htaccess information, use the NCSA authentication tutorial.


COPYRIGHT © 2001-2002 ATLAS-HOST.COM