G
G
git472018-11-29 14:18:46
Apache HTTP Server
git47, 2018-11-29 14:18:46

How to set up the correct redirect from www?

Hello.
Bought SSL. I decided to set up a redirect from http -> https. Without www.
But, there was a problem with one wrong redirect.
If you go to the address: "http:// www.site.ru"
You get: https://site.ru:80/ - and the site does not open on this.
Any other redirects work and open the correct page:
If you just enter -> http:// site.ru -> https://site.ru
If you just enter without http -> site.ru -> https://site.ru
If just enter without http -> www.site.ru -> https://site.ru
Here is the redirect code itself in .htaccess:

<IfModule mod_rewrite.c>
RewriteCond %{ENV:HTTPS} !on
RewriteRule .* - [E=SSL:s]
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ http%{ENV:SSL}://%1/$1 [R=301,L]

RewriteCond %{ENV:HTTPS} !on
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]

RewriteCond %{HTTP_HOST} ^www.site\.ru$ [NC]
RewriteRule ^(.*)$ http://site.ru/$1 [R=301,L]
</IfModule>

Bitrix site engine. Located on the server. nginx
Please help.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Taran, 2018-11-29
@shambler81

this is a misconfigured nginx unfortunately this is quite a common occurrence.
Specify explicitly the domain where to do the redirect, and that's it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question