# HG changeset patch # User Matthew Wild # Date 1336790175 -3600 # Node ID 1fac86aab90b160a97733cf15649e24f9c734b23 # Parent b4219d987d053d3e93f78f04865d6f3af1d4a1f0# Parent 550f0a5e85c5046644b61c24d40503c6aed14b33 Merge with Zash diff -r b4219d987d05 -r 1fac86aab90b plugins/mod_http_files.lua --- a/plugins/mod_http_files.lua Sat May 12 03:24:06 2012 +0100 +++ b/plugins/mod_http_files.lua Sat May 12 03:36:15 2012 +0100 @@ -27,11 +27,18 @@ function serve_file(event, path) local response = event.response; + local orig_path = event.request.path; local full_path = http_base.."/"..path; if stat(full_path, "mode") == "directory" then - if stat(full_path.."/index.html", "mode") == "file" then - return serve_file(event, path.."/index.html"); + if full_path:sub(-1) ~= "/" then + response.headers.location = orig_path.."/"; + return 301; end + if stat(full_path.."index.html", "mode") == "file" then + return serve_file(event, path.."index.html"); + end + + -- TODO File listing return 403; end local f, err = open(full_path, "rb");