Should there be 301 redirect to www with https or just http in Bitrix?

The site has configured a redirect from http to https
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]


When I go to http://www.site.ruhe directed to the http://site.ru(removes www)
But when I go to https://www.site.ru it will not redirect.

How to configure it? .htaccess looks like this:
Options-Indexes 
An ErrorDocument 404 /404.php

RewriteEngine on


RewriteCond %{HTTPS} !=on

RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]



<IfModule mod_php5.c>
 php_flag allow_call_time_pass_reference 1
 php_flag session.use_trans_sid is off

 #php_value display_errors 1

 #php_value mbstring.internal_encoding UTF-8
</IfModule>

<IfModule mod_rewrite.c>
 Options +FollowSymLinks
 RewriteEngine On


 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"
</IfModule>
April 3rd 20 at 18:29
2 answers
April 3rd 20 at 18:31
1 Bitrix nothing to do with it.
2 you Need as you need it. And as you no need need.
3 I'd do anything without www.

Now you have nothing removes www. Just at the entrance there is a redirect from http to https://site.ru
There was a www or not he was resolutely still. You wrote - if http to redirect to https://site.ru, no matter what it was before.

To remove the www, you need to add something like:
RewriteCond %{HTTP_HOST} ^www\.(.*)$
RewriteRule ^(.*)$ https://%1/$1 [L,R=301]

(not tested)
April 3rd 20 at 18:33
I PIAL here
https://klondike-studio.ru/standards/standartnyy-h...

############################################################################
#### Standard .htaccess for project Studio Klondike, version 4.6 ####
############################################################################
RewriteEngine On
 # Directive includes redirects.
RewriteBase / 
 # Without a Directive (.*) = /$1 is /var/wwww/site/web/$1 Directive = /$1
Options +FollowSymLinks
 # Allow symbolic links.
php_flag display_errors off
 # prevent the display of errors (requirement quality monitor)
php_flag allow_url_fopen off
 # to prohibit the use of deleted files (the requirement for proactive protection)

############################################################################
#### Selection of the primary mirror (with www or without www) ####
############################################################################
 # 1. Remove www
RewriteCond %{ENV:HTTPS} on
 #If https is enabled
RewriteRule .* - [E=SSL:s]
 #Create a variable ssl with text s
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
 # Check whether the domain www URL.
RewriteRule ^(.*)$ http%{ENV:SSL}://%1/$1 [R=301,L]
 # Remove www redirect

 # 2. Add www
#RewriteCond %{ENV:HTTPS} on
 #If https is enabled
#RewriteRule .* - [E=SSL:s]
 #Create a variable ssl with text s
#RewriteCond %{HTTP_HOST} !^www\.(.*) [NC]
 # If there is no www at the beginning of the domain
#RewriteRule ^(.*)$ http%{ENV:SSL}://www.%{HTTP_HOST}/$1 [R=301,L]
 #Substitute the www and https if it is enabled.

############################################################################
#### Redirect https to http ####
############################################################################
#RewriteCond %{HTTPS} on
 # Check for the https in the URL.
#RewriteRule ^.*$ http://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
 # Redirect to the http Protocol.

############################################################################
#### Redirect http to https ####
############################################################################
RewriteCond %{HTTPS} off
 # Check for the https in the URL.
RewriteCond %{REQUEST_URI} !^/bitrix/admin/1c_exchange\.php$ [NC] 
 # Exclude exchange with 1C, it requires only 200 
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
 # Redirect to the http Protocol.

############################################################################
#### Remove index.php if it is in the end of the URL ####
############################################################################
RewriteCond %{REQUEST_URI} ^(.*)/index\.php$
 # URL contains index.php in the end.
RewriteCond %{REQUEST_METHOD} =GET
 # Identify the GET request in the URL (not POST).
RewriteRule ^(.*)$ %1/ [R=301,L]
 # Delete index.php URL.

############################################################################
#### Remove duplicate slashes (/) in the URL ####
############################################################################
RewriteCond %{THE_REQUEST} //
 # Check if you can reproduce the forward slash (//) more than two times.
RewriteCond %{QUERY_STRING} !http(s|)://
 # Make sure that this is not the url to GET
RewriteRule .* /$0 [R=301,L]
 # Exclude all the extra slashes.

############################################################################
#### Remove slashes at the end of the URL for static files (contains a dot) ####
############################################################################
RewriteCond %{REQUEST_URI} \..+$
 # If the file contains a dot.
RewriteCond %{REQUEST_FILENAME} !-d
 # And is not a directory.
RewriteCond %{REQUEST_FILENAME} -f
 # Is a file.
RewriteCond %{REQUEST_URI} ^(.+)/$
 # In the end of the URL has a slash.
RewriteRule ^(.+)/$ /$1 [R=301,L]
 # Exclude slash.

############################################################################
#### Add a slash(/), if it is not, and is not a file. ####
############################################################################
RewriteCond %{REQUEST_URI} !(.*)/$
 # If a slash at the end there.
RewriteCond %{REQUEST_FILENAME} !-f
 # Is not a file.
RewriteCond %{REQUEST_URI} !\..+$
 # In the URL there is a point (file).
RewriteCond %{REQUEST_URI} ^(.+)$
 # In a URL there is at least one of the characters
RewriteRule ^(.*)$ $1/ [L,R=301]
 # Add a trailing slash.


############################################################################
#### Compression of static content for Google AIDS test ####
############################################################################
<IfModule mod_deflate.c>
 AddType image/svg+xml .svg
 AddOutputFilterByType DEFLATE image/svg+xml 
 AddOutputFilterByType DEFLATE application/rss+xml
 AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
 AddOutputFilterByType DEFLATE application/x-font
 AddOutputFilterByType DEFLATE application/x-font-opentype
 AddOutputFilterByType DEFLATE application/x-font-otf
 AddOutputFilterByType DEFLATE application/x-font-truetype
 AddOutputFilterByType DEFLATE application/x-font-ttf
 AddOutputFilterByType DEFLATE application/x-javascript
 AddOutputFilterByType DEFLATE application/xhtml+xml
 AddOutputFilterByType DEFLATE application/xml
 AddOutputFilterByType DEFLATE font/opentype
 AddOutputFilterByType DEFLATE font/otf
 AddOutputFilterByType DEFLATE font/ttf
 AddOutputFilterByType DEFLATE image/svg+xml
 AddOutputFilterByType DEFLATE image/x-icon
 AddOutputFilterByType DEFLATE text/css
 AddOutputFilterByType DEFLATE text/html
 AddOutputFilterByType DEFLATE text/javascript
 AddOutputFilterByType DEFLATE text/plain
 AddOutputFilterByType DEFLATE text/xml
 AddOutputFilterByType DEFLATE image/svg+xml
</IfModule>
<IfModule mod_expires.c>
 ExpiresActive on
 ExpiresByType image/jpeg "access plus 1 year"
 ExpiresByType image/svg "access plus 1 year"
 ExpiresByType image/gif "access plus 1 year"
 ExpiresByType image/png "access plus 1 year"
 ExpiresByType text/javascript "access plus 1 year"
 ExpiresByType text/css "access plus 1 year"
 ExpiresByType application/javascript "access plus 1 year"
 ExpiresByType application/vnd.ms-fontobject "access plus 1 year"
 ExpiresByType application/x-font-ttf "access plus 1 year"
 ExpiresByType application/x-font-opentype "access plus 1 year"
 ExpiresByType application/x-font-woff "access plus 1 year"
 ExpiresByType image/svg+xml "access plus 1 year"
</IfModule>
 <IfModule mod_headers.c>
 <filesmatch "\.(ico|flv|jpg|jpeg|webp|png|gif|css|swf|woff|pdf)$">
 Header set Cache-Control "max-age=31536000, public"
</filesmatch>
 <filesmatch "\.(html|htm)$">
 Header set Cache-Control "max-age=7200, private, must-revalidate"
</filesmatch>
 <filesmatch "\.(pdf)$">
 Header set Cache-Control "max-age=86400, public"
</filesmatch>
 <filesmatch "\.(js|otf|ttf|woff|woff2)$">
 Header set Cache-Control "max-age=31536000, private"
</filesmatch>
</IfModule>
############################################################################
#### End common part, followed their own guidelines .htaccess ####
############################################################################

Find more questions by tags Search engine optimization1C-Bitrix