Skip to content

Commit

Permalink
fix: improved NGINX route rewrite handling for '/home' and '/loading' (
Browse files Browse the repository at this point in the history
…#1566)

* addresses issues with trailing slashes for MULTI_CHANNEL configurations without 'baseHref' (introduced with #1553)
* fix "the rewritten URI has a zero length" error in nginx multi channel handling
* prevents canonical links with doubled "/"(slash) between the domain name and the rest of the path
  • Loading branch information
shauke committed Mar 7, 2024
1 parent b589113 commit 052a4ec
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions nginx/templates/multi-channel.conf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@

include /etc/nginx/conf.d/cache-settings.conf;

rewrite ^.*/index.html$ {{ $baseHref }}/loading;
rewrite ^(.*)/$ $1;
rewrite ^{{ $baseHref }}/?$ {{ $baseHref }}/home;
{{- $baseHrefTrailingSlash := $baseHref }}{{ if not ($baseHrefTrailingSlash | strings.HasSuffix "/") }}{{ $baseHrefTrailingSlash = print $baseHrefTrailingSlash "/" }}{{ end }}
rewrite ^.*/index.html$ {{ $baseHrefTrailingSlash }}loading;
rewrite ^{{ $baseHref }}/*?$ {{ $baseHrefTrailingSlash }}home;
rewrite ^(.*?)(/+)$ $1;

rewrite '^(?!.*;lang=.*)(.*)$' '$1;lang={{ $lang }}';
rewrite '^(?!.*;currency=.*)(.*)$' '$1;currency={{ $currency }}';
Expand Down

0 comments on commit 052a4ec

Please sign in to comment.