Skip to content

Instantly share code, notes, and snippets.

@ralexandr
Forked from kevana/mmmmCookies.hbs
Created May 28, 2019 10:30
Show Gist options
  • Save ralexandr/b631702a0c6a9a3eb26c9b7a3e7c73e0 to your computer and use it in GitHub Desktop.
Save ralexandr/b631702a0c6a9a3eb26c9b7a3e7c73e0 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