From 7a7648e6de9a96ee34b177cd1ad1d370e2ace983 Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Fri, 14 May 2021 12:52:29 -0400 Subject: [PATCH] redirect 404 /page/ to /page if /page.html exists --- nginx/nginx.conf | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/nginx/nginx.conf b/nginx/nginx.conf index 6b0a47ed..7b54d0a0 100644 --- a/nginx/nginx.conf +++ b/nginx/nginx.conf @@ -283,11 +283,21 @@ http { internal; } - location ~ "(\.html|/)$" { + location ~ "/$" { include snippets/security-headers.conf; add_header Cross-Origin-Resource-Policy "same-origin" always; add_header Cache-Control "public, no-cache"; include snippets/preload.conf; + try_files ${uri}index.html @noslash; + } + + # redirect /path/ to /path if /path.html exists + location @noslash { + rewrite ^(.*)/$ $1; + if (-f $request_filename.html) { + rewrite ^(.*) $1 permanent; + } + return 404; } location = /install/web {