Skip to content

Instantly share code, notes, and snippets.

@kevana
Last active May 28, 2019 10:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kevana/7b884b2caed1a391f125 to your computer and use it in GitHub Desktop.
Save kevana/7b884b2caed1a391f125 to your computer and use it in GitHub Desktop.
Part of Nginx config for cookie-based routing.
if ($http_cookie ~* (
{{~#each cookies~}}
{{~ this }}{{#unless @last}}|{{/unless}}
{{~/each~}}
)=Y) {
rewrite ^{{ ocpUrl }}$ {{ bcpUrl }} redirect;
}
if ($http_cookie !~* (
{{~#each cookies~}}
{{~ this }}{{#unless @last}}|{{/unless}}
{{~/each~}}
)=Y) {
rewrite ^{{ bcpUrl }}$ {{ ocpUrl }} redirect;
}
if ($http_cookie ~* (bcp_active__my_account|bcp_active__credit_app)=Y) {
rewrite ^/humans.txt$ /address/standardize redirect;
}
if ($http_cookie !~* (bcp_active__my_account|bcp_active__credit_app)=Y) {
rewrite ^/address/standardize$ /humans.txt redirect;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment