E
E
emashev2019-06-20 17:10:47
Nginx
emashev, 2019-06-20 17:10:47

How to set up a redirect in nginx to a string in location?

Greetings, there is such a url:
https://example.com/away?get=https://www.example.r...
Is it possible to set up such a redirect in nginx through regular expressions so that it redirects
to the url that comes after "away?get=" ?
Or, if not possible, how to set up such a rewrite condition: - if the location has "away?get=*"
redirect to another site. Something like:

location ~^/away\?get=.*$ {
      return 301  https://example.ru;
    }

In my case it doesn't work.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2019-06-20
@emashev

server {
    if ($request_uri ~ "^/away\?get=(.+)") {
        return 301 $1;
    }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question