Error redirecting directory pages in Bitrix after switching to https

I ran into a problem: after writing in .htaccess a redirect from http to https, the internal pages of the catalog are redirected to page 404. From what was found on the network, the main culprit has so far been assigned to the Bitrix CNC mechanism.

Tried several different redirection rules, tried placing them before, after, before, and after the Bitrix CNC rules. The result is the same-404 page

Without a redirect in .htaccess, these innermost catalog pages are successfully displayed as for both http and https protocols.

Tell me what the mistake is, don't let me die a fool.

Shtakes (original, redirect to https commented out):

php_value auto_prepend_file "/home/user2050118/www/lor_protect/lor_o.php"

Options -Indexes 
ErrorDocument 404 /404.php

<IfModule mod_php5.c>
  php_flag session.use_trans_sid off
  #php_value display_errors 1
  #php_value mbstring.internal_encoding UTF-8
</IfModule>

<IfModule mod_rewrite.c>
  Options +FollowSymLinks
  RewriteEngine On

#RewriteCond %{SERVER_PORT} !^443$
#RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]

 # редирект c www на без www  
  RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]     
  RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
 # Removes index.php from ExpressionEngine URLs     
  RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]     
  RewriteCond %{REQUEST_URI} !/bitrix/.* [NC]     
  RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]
# Removes index.html from ExpressionEngine URLs     
  RewriteCond %{THE_REQUEST} ^GET.*index\.html [NC]     
  RewriteCond %{REQUEST_URI} !/bitrix/.* [NC]     
  RewriteRule (.*?)index\.html/*(.*) /$1$2 [R=301,NE,L]
 # редирект /news -> /news/  
  RewriteCond %{REQUEST_URI} ^(.*/[^/\.]+)$
  RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1/ [R=301,L]  
 # дублирующие слеши
  RewriteCond %{REQUEST_URI} ^(.*?)/{2,}(.*?/{2,}.*?)$ [NC]
  RewriteRule . %1/%2 [R=301,L]
  RewriteCond %{REQUEST_URI} ^(.*?)/{2,}(.*?)$ [NC]
  RewriteRule . %1/%2 [R=301,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>


Rules urlrewrite.php

<?
$arUrlRewrite = array(
	array(
		"CONDITION" => "#^/countries/#",
		"RULE" => "",
		"ID" => "bitrix:catalog",
		"PATH" => "/countries/america.php",
	),
	array(
		"CONDITION" => "#^/countries/#",
		"RULE" => "",
		"ID" => "bitrix:catalog",
		"PATH" => "/countries/africa.php",
	),
	array(
		"CONDITION" => "#^/countries/#",
		"RULE" => "",
		"ID" => "bitrix:catalog",
		"PATH" => "/countries/index.php",
	),
	array(
		"CONDITION" => "#^/countries/#",
		"RULE" => "",
		"ID" => "bitrix:catalog",
		"PATH" => "/countries/evropa.php",
	),
	array(
		"CONDITION" => "#^/countries/#",
		"RULE" => "",
		"ID" => "bitrix:catalog",
		"PATH" => "/countries/australia.php",
	),
	array(
		"CONDITION" => "#^/countries/#",
		"RULE" => "",
		"ID" => "bitrix:catalog",
		"PATH" => "/countries/azia.php",
	),
	array(
		"CONDITION" => "#^/news/#",
		"RULE" => "",
		"ID" => "bitrix:news",
		"PATH" => "/news/index.php",
	)
);

?>

The potsient itself: http://vsevizy.by

Author: zhurof, 2019-04-15

2 answers

Take a look at this documentation page

Pay attention to the first comment. I had a similar problem. Fixed it by setting the "https_request" variable in .settings.php

 'https_request' =>
    array(
        'value' => true,
    )
 1
Author: MasterMiMiKi, 2019-04-15 19:14:22

Try to make a redirect like this:

RewriteCond %{SERVER_PORT} !^443$
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

%{SERVER_NAME} - the host name in the HTTP server settings and it is most likely different from the name of the site for which you are making a redirect. Use %{HTTP_HOST}

 1
Author: Jigius, 2019-04-19 03:00:42