LoginSignup
45

More than 5 years have passed since last update.

nginxでlocationを使う時の演算子

Posted at

知らなかったのでメモ

# 「=」は完全一致。/index.phpにしか反応しない
location = /index.php {
}

# 無印は前方一致、但し正規表現より弱い
location /index.php {
}

# 「^~」も前方一致、こちらは正規表現より強い
location ^~ /index.php {
}

# 「~」はcase sensitive(大文字と小文字を別に扱う)な正規表現
location ~ ^/index\.php$ {
}

# 「~*」はcase insensitive(大文字と小文字を区別しない)な正規表現
location ~* ^/index\.php$ {
}

~*を知らずに location ~ (jpe?g|JPE?G|gif|GIF|png|PNG)$ とかやっていた。。

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
45