From 3aa253a15d3d210ccb15d7649f5197acda114361 Mon Sep 17 00:00:00 2001 From: Michael Tran Date: Thu, 22 Mar 2018 16:24:50 +1100 Subject: [PATCH 1/3] Clean up rewrite rules and adjust try_files --- nginx.conf | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/nginx.conf b/nginx.conf index f3b5bd3..8e02cc3 100644 --- a/nginx.conf +++ b/nginx.conf @@ -58,29 +58,16 @@ http { # adding some custom rules to strip out the html extension index index.html; - if (!-f "${request_filename}index.html") { - rewrite ^/(.*)/$ /$1 permanent; - } - - if ($request_uri ~* "/index.html") { - rewrite (?i)^(.*)index\.html$ $1 permanent; - } - - if ($request_uri ~* ".html") { - rewrite (?i)^(.*)/(.*)\.html $1/$2 permanent; - } - location / { root <%= ENV["APP_ROOT"] %>/public; - try_files $uri.html $uri $uri/ /index.html; + try_files $uri/index.html $uri.html $uri/ $uri =404; <% if File.exists?(File.join(ENV["APP_ROOT"], "nginx/conf/.enable_pushstate")) %> if (!-e $request_filename) { rewrite ^(.*)$ / break; } <% end %> - index index.html index.htm Default.htm; <% if File.exists?(File.join(ENV["APP_ROOT"], "nginx/conf/.enable_directory_index")) %> autoindex on; <% end %> From cae3ce4cd636fa97ff618c0caf1c1a80262059bf Mon Sep 17 00:00:00 2001 From: Michael Tran Date: Thu, 22 Mar 2018 16:25:48 +1100 Subject: [PATCH 2/3] Pull resources from the webroot in case a subfolder was requested --- www/404.html | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/www/404.html b/www/404.html index 06bd349..d678404 100644 --- a/www/404.html +++ b/www/404.html @@ -32,9 +32,9 @@ - - - + + + @@ -60,7 +60,7 @@

@@ -104,7 +104,7 @@

Sorry, we can’t find the page you’re looking for