2017-02-10 10 views
0

以下のように、より安価な方法がありますか?場所の正規表現 - より良い方法ですか?

http://www.example.com/en-gb/account/death-star-canteen 
http://www.example.com/en-gb/account/cake-or-death 
http://www.example.com/en-gb/account/covered-in-bees 

をし、期限切れのアカウントページにリダイレクト:一致している必要があり

location ~ \/..-..\/account\/(\bdeath-star-canteen\b|\bcake-or-death\b|\bcovered-in-bees\b) { 
      return 301 https://www.example.com/example/expired-account; 
    } 

? en-gbはロケールによって異なる場合がありますか?

また、/ nginx URL正規表現をエスケープする必要がありますか?

答えて

1

それは本当に高価ではないのですか、この文脈では、高価なものを意味を明確にする必要がありますが、それを行うにはより良い方法があります:

location ~ /..-../account/(c(ake-or-death|overed-in-bees)|death-star-canteen) { 
    return 301 https://www.example.com/example/expired-account; 
} 

no need to escape slashesがありますが。

+0

各リクエストに不要な処理を追加するという意味では高価です。 – SpooForBrains

関連する問題