From 2b77f6499b5e00c9e3e745b5ec55988437a401d7 Mon Sep 17 00:00:00 2001 From: Thatsaphorn Atchariyaphap Date: Sun, 8 Jun 2025 21:57:52 +0200 Subject: [PATCH] Add trailing slash redirect rule in nginx.conf to standardize URLs --- nginx.conf | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/nginx.conf b/nginx.conf index 8b54e2d..537e422 100644 --- a/nginx.conf +++ b/nginx.conf @@ -13,6 +13,11 @@ http { server { listen 80; + # Automatically redirect URLs missing trailing slash (but not files like .js, .css, etc.) + if ($request_uri ~ ^([^.\?\#]*[^/])$) { + return 301 $request_uri/; + } + location / { proxy_pass http://main-website:3000; proxy_set_header Host $host;