diff --git a/.github/default.conf b/.github/default.conf index 0640a375..b8561f05 100644 --- a/.github/default.conf +++ b/.github/default.conf @@ -46,15 +46,16 @@ server { return 301 $scheme://digital.sbb.ch$request_uri; } + if ($new_uri) { + rewrite ^ $new_uri permanent; + } + rewrite ^([^.]*[^/])$ $1/ permanent; port_in_redirect off; autoindex off; error_page 404 /error/index.html; location / { - if ($new_uri) { - return 303 $new_uri; - } try_files $uri $uri/ =404; } } \ No newline at end of file diff --git a/src/redirect.njk b/src/redirect.njk index 7b35015b..32ef1df1 100644 --- a/src/redirect.njk +++ b/src/redirect.njk @@ -6,5 +6,5 @@ parent: root eleventyExcludeFromCollections: true permalink: /redirects.txt --- -{% for page in collections.all | include("data.hideInSitemap", true) | exclude("data.external", true) %}{{ page.filePathStem | removeLastPathSegment }} https://digital.sbb.ch{{page.data.redirect}}; +{% for page in collections.all | include("data.hideInSitemap", true) | exclude("data.external", true) %}{{ page.filePathStem | removeLastPathSegment }} {{page.data.redirect}}; {% endfor %} \ No newline at end of file