Views: 24531
Last Modified: 01.04.2014
.htaccess htaccess (hypertext access) is a file of an additional configuration of the Apache web server. It permits you to set a large number of additional parameters and permissions for web server operation in a separate catalog without changing the main configuration file httpd.conf.
The file .htaccess is similar to httpd.conf, the only difference is that it applies only to the catalog where it is located and to its child directories. The file .htaccess may be located in any catalog unless these directives are redefined by directives of underlying .htaccess files. Proper settings of the main configuration file httpd.conf are necessary for the .htaccess files to become usable (the value of the directive AllowOverride must be set as All). The paths to files and catalogu must be indicated from the server root.
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.
Note: During installation, the processing of .htaccess files is verified in the preliminary check step.
In the demonstration site, the file .htaccess contains the following directives by default:
Options -Indexes
ErrorDocument 404 /404.php
<IfModule mod_php5.c>
php_flag allow_call_time_pass_reference 1
php_flag session.use_trans_sid off
#php_value display_errors 1
#php_value mbstring.func_overload 2
#php_value mbstring.internal_encoding UTF-8
</IfModule>
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteCond %{REQUEST_FILENAME} [\xC2-\xDF][\x80-\xBF] [OR]
RewriteCond %{REQUEST_FILENAME} \xE0[\xA0-\xBF][\x80-\xBF] [OR]
RewriteCond %{REQUEST_FILENAME} [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} [OR]
RewriteCond %{REQUEST_FILENAME} \xED[\x80-\x9F][\x80-\xBF] [OR]
RewriteCond %{REQUEST_FILENAME} \xF0[\x90-\xBF][\x80-\xBF]{2} [OR]
RewriteCond %{REQUEST_FILENAME} [\xF1-\xF3][\x80-\xBF]{3} [OR]
RewriteCond %{REQUEST_FILENAME} \xF4[\x80-\x8F][\x80-\xBF]{2}
RewriteCond %{REQUEST_FILENAME} !/bitrix/virtual_file_system.php$
RewriteRule ^(.*)$ /bitrix/virtual_file_system.php [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !/bitrix/urlrewrite.php$
RewriteRule ^(.*)$ /bitrix/urlrewrite.php [L]
RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization}]
</IfModule>
<IfModule mod_dir.c>
DirectoryIndex index.php index.html
</IfModule>
<IfModule mod_expires.c>
ExpiresActive on
ExpiresByType image/jpeg "access plus 3 day"
ExpiresByType image/gif "access plus 3 day"
ExpiresByType image/png "access plus 3 day"
ExpiresByType text/css "access plus 3 day"
ExpiresByType application/javascript "access plus 3 day"
</IfModule>
Note
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 server errors.
- The PHP directive php_flag session.use_trans_sid off disables the session ID in the site URL's.
- 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 directives
php_value mbstring.func_overload 2
and php_value mbstring.internal_encoding UTF-8
control the settings of the mbstring library.
- The directive block
IfModule mod_rewrite.c
- is a setting of rights for mod_rewrite
.
- The directive
AddType application/x-httpd-php .ico
determines the processing of the extension ico as php files.
- 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).
Authorization in the CGI Mode
Sometimes authorization during data exchange with 1C will not work. The problem is often caused by php operating in the CGI mode. This mode experiences problems with HTTP data transmission to php. It can be verified by viewing phpinfo() in the section Server API: CGI
.
The problem may be bypassed, but .htaccess processing and mod_rewrite must be activated on the server. To activate them, please proceed as follows:
- Add the following lines in the file .htaccess of the site root:
RewriteEngine on
RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization},L]
- Comment out the following lines in the file bitrix/admin/.htaccess that deactivate mod_rewrite:
#<ifmodule mod_rewrite.c="">
# RewriteEngine Off
#</ifmodule>
- Add the following lines in the file bitrix/php_interface/dbconn.php:
$remote_user = $_SERVER["REMOTE_USER"]
? $_SERVER["REMOTE_USER"] : $_SERVER["REDIRECT_REMOTE_USER"];
$strTmp = base64_decode(substr($remote_user,6));
if ($strTmp)
list($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) = explode(':', $strTmp);
To check the operability of HTTP authorization, please use the script.
Attention: sometimes this bypass option fails to solve the problem. If after all the recommendations are implemented HTTP authorization fails, please contact your hosting provider about this problem.