LoginSignup
12
11

More than 5 years have passed since last update.

nginx で cookie の値に応じて処理

Posted at

民間にできることは民間で、フロントエンドに出来ることはフロントエンドで。

cookie の hoge に fuga という値があった場合は別のページに飛ばす

if ($cookie_hoge = 'fuga') {
    return 301 /another_page_url;
}

hoge になんかの値が入ってるときは別のページに飛ばす

if ($cookie_hoge != '') {
    return 301 /another_page_url;
}

nginx の if 文は驚くほど機能が少ない (and も else もない) ので大したことは出来ないが、バックエンドの負荷を減らすことは出来そう。

12
11
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
12
11