O
O
olezhenka2018-04-19 23:49:03
Nginx
olezhenka, 2018-04-19 23:49:03

How to create the following condition in nginx?

If the user requests the site address "/" and the sid cookie exists, then redirect to "/account/"
If the user requests any other page and the sid cookie does NOT exist, then redirect to "/"
Here is my code:

map "$cookie_sid:$request_filename" $path {
  default                 $request_filename;
  ":~^/.+"                "/";
  "~.+:/"                 "/account/";
}

location / is worth rewrite ^ $path;

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question