Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

serve http/webdav: redirect requests to the base url without the /

Nick Craig-Wood8bf4697dc224
diff --git a/cmd/serve/httplib/httplib.go b/cmd/serve/httplib/httplib.go
index d28fe253f..a5d6b2618 100644
--- a/cmd/serve/httplib/httplib.go
+++ b/cmd/serve/httplib/httplib.go
@@ -402,6 +402,11 @@ func (s *Server) Path(w http.ResponseWriter, r *http.Request) (Path string, ok b
return Path, true
}
if !strings.HasPrefix(Path, s.Opt.BaseURL+"/") {
+ // Send a redirect if the BaseURL was requested without a /
+ if Path == s.Opt.BaseURL {
+ http.Redirect(w, r, s.Opt.BaseURL+"/", http.StatusPermanentRedirect)
+ return Path, false
+ }
http.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound)
return Path, false
}