E
E
ESSES18682018-05-26 10:50:41
Digital certificates
ESSES1868, 2018-05-26 10:50:41

Redirect HTTPS, WWW. How?

Hi guys! My site

was at www.site.ru. Connected an SSL certificate for site.ru . Now I need to redirect http > https and also www to non-www.

The options below work. But the redirect from httpS://WWW.site.ru does not work .

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

RewriteCond %{HTTPS} off
RewriteCond %{HTTP :X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI } [L,R=301]

What should I do? Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Dubrovin, 2018-05-26
@ESSES1868

RewriteEngine On
RewriteCond %{HTTP_HOST} !^site.ru$ [NC,OR]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://site.ru$1 [R=301,L]

The redirect requires that there is a certificate for www.site.ru, it can be either a separate certificate or one of the alternative names in the main certificate.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question