T
T
TimChorney2020-07-11 12:34:16
Nginx
TimChorney, 2020-07-11 12:34:16

Nginx, how to redirect any requests to the server to a specific URL?

How to properly configure Nginx so that when accessing it on port 80 (to any domain), it redirects to a specific URL with passing parameters (URI) and adding UTM tags?

For example, with sourcedomain.com/signup/new , redirect to target.com so that the URL is formed: target.com/signup/new?utm_source=redirect&utm_medium=sourcedomain.com .

It is very important to transfer the domain to utm_medium, so that later you can understand from the analytics which domains you came from.

There can be an indefinitely many domains, and I would only like to limit myself to registering NS records to the redirect server at the registrar once, and not writing anything in nginx itself.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2020-07-11
@TimChorney

server {
    listen 80 default_server;

    rewrite ^/(.*)  http://target.com/$1?utm_source=redirect&utm_medium=$host;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question