In most cases, a user cannot access the server configuration file (httpd.conf) because its scope affects all users. The file
.htaccess enables you to make changes in configuration which will affect your site only.
The server configuration file httpd.conf must have a directive allowing to use .htaccess
files. Otherwise, the system will ignore these files.
The .htaccess file contains directives whose scope is constrained to the directory in which it resides as well as all subdirectories.
.htaccess in the server root directory affects all the server except directories having their own
.htaccess file. The .htaccess directives are applied in the same order as they are specified. Hence, directives of the
.htaccess file in the given directory have higher priority than those of the parent directories.
You do not need to restart server after you have modified the .htaccess file. This file is checked each time the server is queried, that’s why changes take into effect right away. As this is the system file, it cannot be accessed by users from their browser.
Generally, the .htaccess syntax is similar to the main configuration file. However, the file power may be limited by the
AllowOverride directive. It defines which types of the .htaccess directives can override those of the preceding directives.
The shipped .htaccess file has the following default directives.
ErrorDocument 404 /404.php
#php_flag session.use_trans_sid off
#php_value display_errors 1
#php_value allow_url_fopen 0
AddType application/x-httpd-php .ico
DirectoryIndex index.php index.html
ExpiresByType image/jpeg "access plus 3 day"
ExpiresByType image/gif "access plus 3 day"
php_value error_reporting 7
php_value error_reporting 0
To activate the commented PHP directives, you have to remove the comment operator (#) at the
beginning of each line. If your Apache server does not allow PHP flags, these directives will
incur an internal server error (500). If this is the case, comment these directives back.
Other uncommented PHP directives are enclosed in the verification condition statements ensuring
the required Apace modules are present in the system. These directives will never cause the
- The PHP directive php_flag session.use_trans_sid off disables the session ID in the
- If the PHP flag php_value display_errors is set to 1, the error messages are enabled
and displayed. The directive php_value error_reporting defines which level of PHP
interpreter errors is displayed.
- The directive ExpiresActive on enables image caching which boosts their download
speed on the repeated queries.
ExpiresByType image/jpeg "access plus 3 day" and ExpiresByType image/gif
"access plus 3 day" define the cached image format and the caching period. By
default, .jpeg and .gif files are cached for 3 days.
Note! The file .htaccess must be saved in the UNIX format (Save as UNIX text option
in the FAR manager editor).
Requisite access rights at server |
| Possible database failures