Simultaneous redirect from www to non-www and http to https on Bitrix?

Hi all.

Simultaneous set up a redirect from www to non-www and http to https on Bitrix. This leads to
The website test.ru performed the redirect too many times.


RewriteEngine on

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

RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}


I tried this method on other cms, everything works fine. Bierce falls on the endless forwarding.

What could be the problem?
June 8th 19 at 17:20
1 answer
June 8th 19 at 17:22
Solution
############################################################################
#### 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 %{ENV: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 %{ENV:HTTPS} !on
 # Check for the https in the URL.
#RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
 # Redirect to the http Protocol.

Here for Bitrix, and the problem you have with the cycle due to the nginx+apache configuration.
https://klondike-studio.ru/standards/standartnyy-h...

Find more questions by tags 1C-Bitrixhtaccess