diff options
author | Kim Alvefur <zash@zash.se> | 2012-05-12 02:17:08 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2012-05-12 02:17:08 +0200 |
commit | 090589dd4b191c1f0a246422e74e8922d8e5cfa4 (patch) | |
tree | 9d8ed81a3b20521d2dd1b5306c9eadd702f91049 /plugins | |
parent | 7aac87fba842b093bbb339dff9f8c6f305e1faa8 (diff) | |
download | prosody-090589dd4b191c1f0a246422e74e8922d8e5cfa4.tar.gz prosody-090589dd4b191c1f0a246422e74e8922d8e5cfa4.zip |
mod_http_files: Respond with a 301 redirect for directories to append a / (fixes relative links)
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/mod_http_files.lua | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/plugins/mod_http_files.lua b/plugins/mod_http_files.lua index dc58ff5d..bdc3a011 100644 --- a/plugins/mod_http_files.lua +++ b/plugins/mod_http_files.lua @@ -27,11 +27,18 @@ local mime_map = { 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"); |