diff --git a/caddy/setup/rewrite.go b/caddy/setup/rewrite.go index 4c84cb5f..badbaaee 100644 --- a/caddy/setup/rewrite.go +++ b/caddy/setup/rewrite.go @@ -40,9 +40,6 @@ func rewriteParse(c *Controller) ([]rewrite.Rule, error) { var ifs []rewrite.If switch len(args) { - case 2: - rule = rewrite.NewSimpleRule(args[0], args[1]) - simpleRules = append(simpleRules, rule) case 1: base = args[0] fallthrough @@ -88,8 +85,11 @@ func rewriteParse(c *Controller) ([]rewrite.Rule, error) { return nil, err } regexpRules = append(regexpRules, rule) + + // the only unhandled case is 2 and above default: - return nil, c.ArgErr() + rule = rewrite.NewSimpleRule(args[0], strings.Join(args[1:], " ")) + simpleRules = append(simpleRules, rule) } } diff --git a/caddy/setup/rewrite_test.go b/caddy/setup/rewrite_test.go index c43818b2..c0dd2fb9 100644 --- a/caddy/setup/rewrite_test.go +++ b/caddy/setup/rewrite_test.go @@ -50,8 +50,8 @@ func TestRewriteParse(t *testing.T) { }}, {`rewrite a`, true, []rewrite.Rule{}}, {`rewrite`, true, []rewrite.Rule{}}, - {`rewrite a b c`, true, []rewrite.Rule{ - rewrite.SimpleRule{From: "a", To: "b"}, + {`rewrite a b c`, false, []rewrite.Rule{ + rewrite.SimpleRule{From: "a", To: "b c"}, }}, }