summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Micay <danielmicay@gmail.com>2021-05-14 12:52:29 -0400
committerDaniel Micay <danielmicay@gmail.com>2021-05-14 13:12:51 -0400
commit7a7648e6de9a96ee34b177cd1ad1d370e2ace983 (patch)
tree7378b798f6f8b8e5e1a78918f8564c1531576d73
parent372046813f46d942483f3295dde07e80ff314336 (diff)
redirect 404 /page/ to /page if /page.html exists
-rw-r--r--nginx/nginx.conf12
1 files changed, 11 insertions, 1 deletions
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 {