M
M
mr_drinkens892015-02-13 09:31:35
Django
mr_drinkens89, 2015-02-13 09:31:35

How to redirect to a subdomain of the django nginx main page?

Please help.
The task is this. I have a django project located on the example.com domain.
There is a main page in the form of a landing page. You need to make sure that the main page opens on the subdomain lp.example.com, and all the rest - on example.com.
Is it possible to solve this only on the nginx side?
Thank you

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
stup1d, 2015-02-13
@stup1d

I'm not an nginx expert, but you can. For example (I think the nested location can be bypassed):

server {
    ...

    location / {
        location ~* ^/$ {
            return 301 $scheme://subdomain.example.com/;
        }

        ...
    }

}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question