B
B
Bermut2021-08-15 20:43:16
Nginx
Bermut, 2021-08-15 20:43:16

How to set up a redirect from the main page to another domain?

In general, I want to make a server where all files for other projects will be stored, and they were accessed via the web, that is, I don’t need a main page, how to set up a redirect to the main site.

For example, if there is a request to 2domain.com, it is redirected to domain.com
And if the request is 2domain.com/test.png (this picture is on the server), then it is not redirected anywhere.
And if the request is 2domain.com/asdasdasd.png (this image is not on the server), then it is redirected to domain.com

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
ky0, 2021-08-15
@Bermut

Everything you want is easily implemented within the framework of the basic functionality of nginx. Thoughtful reading of the documentation one , two and mana for the directives location, rewrite, try_files.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question