print PDF
.htaccess file functions


Before proceeding, it is necessary to specify some things about the .htaccess files. First of all, understand that these files work only for web servers. These files will not appear in your directory if an internet web surfer tries to gain access a listable directory (not containing the index page where listing is not allowed.

Next, you should take into account that the .htaccess file parameters apply to the directory and sub-directories of where the file is installed.

What can I do with a .htaccess file?

The two following interesting pieces of information concern the protection and access for your web site:
HtaccessProtection - directory protection via authentication HtaccessProtectIP - prevent certain IP addresses from access to your site

You can also perform other operations such as those listed below...

Prevent the listing of directory contents

To prevent certain web surfers from viewing index files (.cgi; .html; .php etc...) in certain directories, create a .htaccess file that contains the following line:
Options - Indexes

Redirect error messages

If you wish to use personalized error messages or wish to redirect the error messages to a web page, create a .htaccess file containing the following lines:
ErrorDocument number_of_error message_or_destination
Replace "number_of_error" with the corresponding message. The 3 most common errors are :
404 : non-existant page
403 : access forbidden
500 : internal server error

Replace "message_or_destination" with the task to be completed. To post a message, simply type the corresponding message in quotes. To redirect to another page, enter the address of the page. Here are two examples:

You wish to post/inform "Sorry, you do not have access to this file." due to an 403 error. Put the following line in your .htaccess :
ErrorDocument 403 "Sorry, you do not have access to this file"

You wish to post a 404 error on your website. (for your domain: :

If this does not work, check for the following in your the Internet Explorer properties
-onglet Advanced
-de-select "Show simplified HTTP error messages".

Specify a different index file
By default, the index file of a directory is index.html, index.htm or index.php. If you want another file to be the index, you must put the following command in your .htaccess file:
DirectoryIndex name_of_file

For example, if you want to use home.html for your index page, enter the following lines:
DirectoryIndex home.html

Rewrite the URL
You can, for many reasons, rewrite the URLs of your site. For this, you can use the following .htaccess command"
RewriteEngine on
RewriteRule rewrite_rule

Just replace "rewrite_rule" with the rule you want to use. You can write several different rules in the same file. Unfortunately we cannot explain this in further detail, because the possibilities are too numerous and the needs are too diverse. Please refer to the official document for more details: