K
K
KSinner2017-02-16 19:27:45
htaccess
KSinner, 2017-02-16 19:27:45

How to make a redirect from HTTP to HTTPS, but only for the .RU domain, and not for the .KZ mirror + specific Rucenter hosting?

Good afternoon.
Please tell me htaccess file experts.
There is a site with an SSL certificate, say - sport.ru

It has several mirror subdomains:
msk.sport.ru
spb.sport.ru

And also, there is a mirror for Kazakhstan sport.kz + one subdomain almaty.sport.kz - without SSL certificate.

This site lives on NIC.ru and there, if I understand correctly, only this entry works for redirecting from HTTP to HTTPS:


RewriteCond %{SERVER_PORT} !^443$
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI } [R,L]


However, if I write this, then I get messages about a missing certificate for sport.kz + almaty.sport.kz

Question: how can I make the redirect work only for sport.ru + subdomains, but not for sport.kz + almaty .sport.kz At the same time, I would like if a user who goes to https://sport.kz - to be redirected to sport.kz Tried
a lot of options - nothing helps. I still get an error when I go to https://sport.kz (does not redirect to sport.kz ).

There are a lot of examples on the Internet, but on nic.ru I only have this check - RewriteCond %{SERVER_PORT} !^443$
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Taran, 2017-02-17
@shambler81

RewriteCond %{SERVER_PORT} !^443$
RewriteCond %{HTTP_HOST} !^не такой домен [NC]
RewriteCond %{HTTP_HOST} !^и  не такой не такой домен [NC]
RewriteCond %{HTTP_HOST} !^и так далее [NC]
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R,L]

Well, from the opposite
RewriteCond %{SERVER_PORT} !^443$
RewriteCond %{HTTP_HOST} ^sport\.ru  [NC]
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R,L]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question