M
M
monyavitevna2018-04-13 09:43:49
Nginx
monyavitevna, 2018-04-13 09:43:49

How to make a redirect from a subdomain to the main domain?

Hello.
There is a main domain https://topligarun.ru/ on Bitrix. the sales regions module is installed.
There are many subdomains by city.
The task is to make a redirect to the main domain from some cities.
For example, https://anapa.topligarun.ru/ etc.
Tell me where to do it in nginx or apache, and how to do it right?
I've tried it here and there, it doesn't work.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Kev, 2018-04-13
@Kev

server {
    listen       80;
    server_name  anapa.topligarun.ru msk.topligarun.ru spb.topligarun.ru; 
    return       301 http://topligarun.ru$request_uri;
}
server {
    listen       80;
    server_name  topligarun.ru
    #тут основной конфиг
}

R
Reversaidx, 2018-04-13
@Reversaidx

if ($host != topligarun.ru  )
{return 301 https://topligarun.ru$request_uri;}

Something like this

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question