From 7ed515dba8b29f1099cc3e66f364244e4bec1668 Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Fri, 1 Jul 2016 15:51:02 +0100 Subject: [PATCH] one more thing --- config/config.go | 3 ++- filemanager.go | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/config/config.go b/config/config.go index 0161d5c1..a8637c56 100644 --- a/config/config.go +++ b/config/config.go @@ -16,6 +16,7 @@ type Config struct { Root http.FileSystem BaseURL string AbsoluteURL string + AddrPath string StyleSheet string // Costum stylesheet FrontMatter string // Default frontmatter to save files in HugoEnabled bool // Enables the Hugo plugin for File Manager @@ -77,7 +78,7 @@ func Parse(c *caddy.Controller) ([]Config, error) { caddyConf := httpserver.GetConfig(c) cfg.AbsoluteURL = caddyConf.Addr.Path + "/" + cfg.BaseURL cfg.AbsoluteURL = strings.Replace(cfg.AbsoluteURL, "//", "/", -1) - + cfg.AddrPath = strings.TrimSuffix(caddyConf.Addr.Path, "/") cfg.Root = http.Dir(cfg.PathScope) if err := appendConfig(cfg); err != nil { return configs, err diff --git a/filemanager.go b/filemanager.go index af819b8a..e7572977 100644 --- a/filemanager.go +++ b/filemanager.go @@ -54,7 +54,7 @@ func (f FileManager) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, err } if fi.IsDir && !strings.HasSuffix(r.URL.Path, "/") { - http.Redirect(w, r, r.URL.Path+"/", http.StatusTemporaryRedirect) + http.Redirect(w, r, c.AddrPath+r.URL.Path+"/", http.StatusTemporaryRedirect) return 0, nil } }