S
S
sochi-russia2017-03-03 22:03:11
htaccess
sochi-russia, 2017-03-03 22:03:11

301 redirect from www to non-www with https doesn't work, why?

.htaccess

RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\.
RewriteRule (.*) https://site.ru/$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule .* - [L]
RewriteRule .* ./index.php [L,QSA]
RewriteCond %{HTTP_HOST} ^www.site.ru$ [NC]
RewriteRule ^(.*)$ http://site.ru/$1 [R=301,L]

It is necessary that when you enter www.site.ru redirects to site.ru with https For some reason, the above code does not redirect. If you enter https://www.site.ru , it still goes to https://www.site.ru , but it is necessary that the 301st redirect goes to https://site.ru and the same when you enter www. site.ru redirected to https://site.ru , and site.ru redirected to https://site.ru Thank you

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question