Cyberiot Home

Budget Hosting

Domain Search

Server Hardware

Free Newsletter

Search Website

FAQ

Support

Set-up Domain

 Contact Us

Recommend this Site

 

Renew Domain

 

.htaccess

HTTP Headers

Learn all about HTTP Headers from w3.org

What is .htaccess?

Important Note: Do not edit the .htaccess file if you are using Microsoft® Frontpage® extensions! Frontpage uses the .htaccess file, and editing it may cause errors in your configuration. 

When a request for a web page is made, the web server first checks for an .htaccess file. 

The server begins this check by looking for .htaccess in the root of the current web directory, and on down the directory tree until it reaches the directory where the requested file resides. 

Since the placement of the .htaccess file determines when it is executed, this fact can be used to restrict access only in certain subdirectories.

Functions

Redirect hits onto another webpage.

Control and set the messages generated for various error conditions.

Edit Mime-types.

Activate and deactivate various server features.

To create an .htaccess file, make a text file as described below, name it .htaccess and upload it.

The following features will only work for a .htaccess file placed in /home/$user/$domain-www. Add all features you want to the same file.

Redirects

Redirecting allows you to send the user to, for example, new.html when they attempt to access old.html. To see this example in practice, simply add the following line to the .htaccess file:

Redirect /$directory/old.html http://$domain.com/$directory/new.html

Error Documents

There are two main styles of error messages you may encounter. The first is the standard form, which looks something like: 

File Not found

The requested URL http://$domain.com/file.html was not found on this server.


The second type comes in a variety of forms, and is customized by the webmaster. For example:

Sorry

We're sorry, but the requested URL does not exist. Please e-mail support@$domain.com if you need further assistance.


Such messages are called error documents, and are web pages designed to give a polite explanation for error conditions. These error conditions generate numbers which are used to refer to the appropriate error condition. Some of the most common messages are as follows:

Error in Client 

400 Bad syntax
401 Unauthorized
402 Not Used (Payment Granted)
403 Forbidden
404 Not Found

Error in Server 

500 Internal Error
501 Not Implemented
502 Overloaded
503 Gateway Timeout

Learn all about HTTP Headers from w3.org

How to Customize Error Messages for Your Site:

First, create the HTML page you want to use as your error message.
Second, upload it to your web directory [/home/$user/$domain-www].
Third, go into your .htaccess file (or create one) and add lines which specify the substitution.

Here are three examples of specifying error documents which will be called for a given error condition (note you can use relative or absolute addressing): 

ErrorDocument 401 http://$domain.com/nopasswd.html
ErrorDocument 403 /forbidden.html
ErrorDocument 404 http://www.$domain.com/nofile.html

Mime Types

You can add mime types to your .htaccess file with a line like:

AddType text/html .txt
-----------------------------------------

 

Cyberiot
Newsletter

Learning Series / HOW-TO create dynamic Webs

We write our own newsletter which is distributed free of charge. Articles of value, cut-and-paste scripts, free resources and success stories. 

Opt out at any time, no obligation to buy a single thing. We won't bore you with a million articles each week, short and to the point. Begin learning today.

  • How can scripts help me? 
  • Do I need a Database?
  • What to do with it!

What to expect?

  • MySQL tutorial
  • PHP tutorial
  • Cut and Paste codes to get you going
  • Simple layman's solutions for your site and budget problems
  • How-to save big bucks with small codes
Your Name:
Your E-mail Address:

 



Home FAQ Hosting Servers Support Contact
Search Domain Search Domain Renewal Affiliate Pass this on Policy

CyberRiot.net services may not be used for sites containing or linking to nudity or other pornographic material, illegal material, or other objectionable content.

Security software monitors our network every second of every day. Spamming software or porn are not allowed.

© Copyright 1999 - 2002 Cyberiot.com
All Rights Reserved