diff --git a/caddytest/integration/caddyfile_adapt/file_server_disable_canonical_uris.txt b/caddytest/integration/caddyfile_adapt/file_server_disable_canonical_uris.txt new file mode 100644 index 000000000..c30b9e95f --- /dev/null +++ b/caddytest/integration/caddyfile_adapt/file_server_disable_canonical_uris.txt @@ -0,0 +1,32 @@ +:80 + +file_server { + disable_canonical_uris +} +---------- +{ + "apps": { + "http": { + "servers": { + "srv0": { + "listen": [ + ":80" + ], + "routes": [ + { + "handle": [ + { + "canonical_uris": false, + "handler": "file_server", + "hide": [ + "./Caddyfile" + ] + } + ] + } + ] + } + } + } + } +} diff --git a/modules/caddyhttp/fileserver/caddyfile.go b/modules/caddyhttp/fileserver/caddyfile.go index 447f4811c..886d6672c 100644 --- a/modules/caddyhttp/fileserver/caddyfile.go +++ b/modules/caddyhttp/fileserver/caddyfile.go @@ -41,6 +41,7 @@ func init() { // browse [] // precompressed // status +// disable_canonical_uris // } // func parseCaddyfile(h httpcaddyfile.Helper) (caddyhttp.MiddlewareHandler, error) { @@ -112,6 +113,13 @@ func parseCaddyfile(h httpcaddyfile.Helper) (caddyhttp.MiddlewareHandler, error) } fsrv.StatusCode = caddyhttp.WeakString(h.Val()) + case "disable_canonical_uris": + if h.NextArg() { + return nil, h.ArgErr() + } + falseBool := false + fsrv.CanonicalURIs = &falseBool + default: return nil, h.Errf("unknown subdirective '%s'", h.Val()) }