K
K
Konstantin Rudenko2017-05-15 13:45:26
htaccess
Konstantin Rudenko, 2017-05-15 13:45:26

How to redirect a site without changing the protocol to www?

Hello.
Please tell me, who knows what rules to prescribe in htaccess so that a redirect occurs from a site without www to www without changing the protocol, i.e.
ht tps://site_name.ru >>>>> ht tps://www.site_name.ru ht tp: //site_name.ru
>>>>> ht tp://www.site_name.ru
there were no more redirects.
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Taran, 2017-05-15
@shambler81

Well, for example.

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

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

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question