Answer the question
In order to leave comments, you need to log in
How to set up multiple domains for one site on nginx?
There is a site working for example on the test.ru domain, a second domain is bought, for example supertest.com, it is connected to the same site, a virtual host is configured. You can go through supertest.com, but all links on the site lead to the default domain (in the base of the engine), i.e. at test.ru Moreover, it is important that the rewrite be conditional, i.e. if we go through test.ru, then the links should be to it, if we go through supertest.com, then the links should be to it. I know for sure that it is possible to change links from test.ru to supertest.com through rewriting, but I can’t find how. Please help.
ps Business happens on pure nginx.
Answer the question
In order to leave comments, you need to log in
The most correct variant is to decide at the level of the engine and editing the base.
This task can be solved by nginx using the data replacement module in the body nginx.org/ru/docs/http/ngx_http_sub_module.html
In the example, there is even something that you need - replacing a fixed string with $host - name domain in the request.
But I would use this solution as a temporary solution, and would plan to change the base because it is much more transparent for further development and maintenance of the configuration.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question