From d9ab7e77c1c2d37e48c98fe275ce75a7b77f78fc Mon Sep 17 00:00:00 2001 From: Steven Polley Date: Fri, 29 May 2020 21:00:52 -0600 Subject: [PATCH] add support for redirect types in config --- config.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/config.go b/config.go index 48b820c..59f02e8 100644 --- a/config.go +++ b/config.go @@ -24,15 +24,22 @@ func config(redirects []Redirect) error { return fmt.Errorf("unable to parse source URL '%s': %v", redirect.sourceURL, err) } - var ruleName string + var ruleName, action string if len(redirect.sourceURL) > 63 { // FortiOS only allows up to 63 characters ruleName = redirect.sourceURL[:62] } else { ruleName = redirect.sourceURL } + + if redirect.statusCode == 301 { //translate to fortiOS syntax + action = "redirect-301" + } else { + action = "redirect" + } + fmt.Printf("edit \"%s\"\n", ruleName) fmt.Printf("set location %s\n", redirect.destinationURL) - fmt.Println("set action redirect") + fmt.Printf("set action %s\n", action) fmt.Println("config match-condition") fmt.Println("edit 0") fmt.Println("set object http-url")