server { listen 80; listen [::]:80; server_name localhost; rewrite ^/(.*)/$ /$1 permanent; # truncate forward slash root /var/www/html; error_page 404 /error-404.html; location = /error-404.html {} location = / { index index.html; } location / { try_files $uri $uri.html =404; } location ~* ^\/blog\/(.*)$ { try_files /blog-$1.html =404; } }