Answer the question
In order to leave comments, you need to log in
HTTP authentication not working on HTTPS site?
There is a site (not Bitrix!) with which integration with 1C is configured.
1C sends requests to: http://site/bills/1c_exchange
The site works over HTTPS, so in .htaccess:
RewriteEngine on
RewriteCond %{SERVER_PORT} !^443$
RewriteCond %{THE_REQUEST} !/bills/1c_exchange [NC]
RewriteRule ^(.*)$ https://сайт.ru/$1 [R=301,L]
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php
if ($_SERVER['PHP_AUTH_USER']) {
if ($_SERVER['PHP_AUTH_USER'] == $options['1с_login'] and
$_SERVER['PHP_AUTH_PW'] == $options['1c_password'] ) {
if ($mode == 'checkauth') {
echo "success\nexchange_1c_key\n$exchange_1c_key";
exit();
}
} else {
exit('Ошибка доступа! Неправильный логин или пароль!');
}
} else {
header('WWW-Authenticate: Basic realm="My Realm"');
header('HTTP/1.0 401 Unauthorized');
exit();
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question