S
S
Sergey2014-02-17 15:47:01
Nginx
Sergey, 2014-02-17 15:47:01

How to make a dynamic redirect in nginx?

Hey!
Please tell me how to set up a dynamic redirect in nginx, so that what comes after some given url redirects to the main page. Tried like this -

location = /products(.*)$ { rewrite ^ http://site.ru/ permanent; }

- Does not help. Thanks in advance!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vit, 2014-02-17
@mr_Verman

At least - a tilde instead of an equal sign, if you want to set the location with a regular expression

G
grossws, 2014-02-20
@grossws

And better not use premanent(301) but redirect(302). If you have to change it later, there will be problems (clients will have cached 301s).
Also, when this change
to
See wiki.nginx.org/Pitfalls

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question