Answer the question
In order to leave comments, you need to log in
How to set cookie existence condition on nginx for redirect?
I need the following conditions:
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 "/"
left me:
location ~* ^/$ {
if ($cookie_sid != "") {
rewrite ^(.*)$ /account/ last;
}
}
location / {
if ($cookie_sid = "") {
rewrite ^(.*)$ / break;
}
try_files $uri $uri/ /index.html;
expires 7d;
}
Answer the question
In order to leave comments, you need to log in
if doesn't work the way you think
https://www.nginx.com/resources/wiki/start/topics/...
Use map
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question