A
A
Alexander2017-10-24 21:12:50
Nginx
Alexander, 2017-10-24 21:12:50

How to redirect GET requests with saving parameters?

Hello, I need help in solving a problem that has arisen, how to use nginx to redirect GET requests to another domain, for example, there is a request:


https://site1.ru/page?a=1&b=2

How to redirect it to:

https://site2.ru/page?a=1&b=2

using preferably nginx ?
The purpose of all this: It is necessary to redirect all requests from one domain to another, while maintaining the entire URL.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexandr, 2017-10-24
@QcfgAlexandr

Response:
server {
listen IP:80;
server_name requested_domain.tld;
rewrite ^ http://target_domain.tld$request_uri;
}

V
vitaliy2, 2018-02-06
@vitaliy2

With path change:
Without changing the path: If proxying was meant, then:

proxy_pass        http://…;
proxy_set_header  Host <подставить>;
proxy_set_header  Connection "";

# Также если нужно изменить путь, то, возможно, нужно добавить rewrite:
rewrite .* /newPath;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question