A
A
Asker18882020-05-08 15:11:40
htaccess
Asker1888, 2020-05-08 15:11:40

How to write a 301 redirect from www in .htaccess?

Good afternoon.
I'm trying to set up a 301 redirect on a hosting, but I don't understand how to write something correctly.
Now the whole .htaccess looks like this:

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


What and where should I write in order to redirect from https://www.site.ru to just https://site.ru? (https is already registered and working)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2020-05-08
@Asker1888

RewriteEngine On
RewriteCond %{ENV:HTTPS} !on    [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule ^.*$ https://site.ru/$0 [L,R=301]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question