matches_regex replacement

Hi,

we are using an i-rule to perform some redirects for a site. A recent addition to the rule doesn’t appear to be working as we wanted it and I’m aware matches_regex is not the best solution so how can we replace this:

elseif { $uri matches_regex {^/(uk|test|news|marketing)/.*/$ }} {
    HTTP::respond 301 Location "https://www.company.com[HTTP::uri]default.page"

any advice appreciated.

thanks

A

Hi Andrew,

try this out:

when HTTP_REQUEST {

    switch -glob [string tolower [HTTP::uri]] {
        "/uk*" -
        "/test*" -
        "/news*" -
        "/marketing*" {
            HTTP::respond 301 Location "https://www.company.com[HTTP::uri]default.page"
            }
    }
}

Regards Andréas

Thanks Andreas, I might try that (we have a test environment). Someone also suggested using “ends_with” so might try that too like this, if I have the syntax right!:

elseif { [HTTP::uri] ends_with "/" } {
    HTTP::respond 301 Location "https://www.company.com[HTTP::uri]default.page"
}