HTTP redirect to HTTPS and add domain but leave it off if already added

Two scenarios here.. user enters or

Getting to become is done with this part of the iRule

when HTTP_REQUEST { if {([HTTP::host] contains “vipaddress”)} then { HTTP::redirect “https://[HTTP::host].example.local” } } (This returns from just

I am having issues with what to do if the user enters so it doesn’t add an additional .example.local at the end. I’m failing on the elseif part. Also if a user enters vipaddress/sitefolder/site would the redirect be “https://[HTTP::host]/[HTTP::uri]”

Hi,

why do you want to add if you know the expected result?

try this code:

when HTTP_REQUEST {
    switch [HTTP::host] {
        "vipaddress" -
        "vipaddress.example.local" {
            HTTP::redirect "https://vipaddress.example.local[HTTP::uri]"
        }
    }
}

you can also try this:

when HTTP_REQUEST {
    switch [HTTP::host] {
        "vipaddress" -
        "vipaddress.example.local" {
            HTTP::redirect "https://[getfield [HTTP::host] "." 1].example.local[HTTP::uri]"
        }
    }
}