Redirect Examples on FortiWeb

Redirects / Rewrites

To use redirects or rewrite rules, you’ll first have to configure the Rule (check out the Examples below e.g. http to https) and then you’ll have to add this rule in a URL Rewriting Policy.

This URL Rewriting policy will be used in a Web Protection Profile which you’ll use in your Server Policy.

Redirect from http to https with a Rewriting Rule

 config waf url-rewrite url-rewrite-rule
  edit "http_to_https"
    set location https://$0/$1
    config  header-removal
    end
    set action redirect
    config  match-condition
      edit 1
        set reg-exp (.*)
        set protocol-filter enable
      next
      edit 2
        set object http-url
        set reg-exp ^/(.*)$
      next
    end
  next
end

Redirect from https://www.c3it.net/ to https://www.c3it.net/redirectdestinationurl/

config waf url-rewrite url-rewrite-rule
    edit "REDIR_www.c3it.net"
        set location https://www.c3it.net/redirectdestinationurl/
        config header-removal
        end
        set action redirect-301
        config match-condition
            edit 1
                set reg-exp ^www.c3it.net$
                set protocol-filter enable
                set HTTP-protocol https
            next
            edit 2
                set object http-url
                set reg-exp ^/$
                set protocol-filter enable
                set HTTP-protocol https
            next
        end
    next
end