Forum Discussion

Raja_M's avatar
Raja_M
Icon for Nimbostratus rankNimbostratus
Mar 15, 2019

Getting error in IRULE for string map

Im Getting error for IRULE

error: [parse error: extra characters after close-brace][[HTTP::uri]] -------

Remove /content/abc from all requests
set RemoveContent 1
set RemoveContentSubOne 1
set RemoveContentSubTwo 0
set RemoveContentSubThree 1
if {$RemoveContent > 0} {
    if {([string tolower [HTTP::uri]] starts_with "/content/abc/apac/")
        or ([string tolower [HTTP::uri]] starts_with "/content/abc/emea/")
        or ([string tolower [HTTP::uri]] starts_with "/content/abc/latin-america/")
        or ([string tolower [HTTP::uri]] starts_with "/content/abc/")
       } {
        if {$RemoveContentSubOne > 0} {
            if {[string tolower [HTTP::host]] eq "sys-axecess.abc.com"} {
                if {([string tolower [HTTP::path]] contains "jcr_content") or ([string tolower [HTTP::path]] contains "jcr:content")}{
                    return
                } else {
                    set Redirected 1
                    set NoContentabc [string map -nocase {"/content/abc/apac/" "/" "/content/abc/emea/" "/" "/content/abc/latin-america/" "/" "/content/abc/" "/"}[HTTP::uri]]
                    HTTP::respond 301 location "https://sys-axecess.abc.com/$NoContentabc"
                    return
                }
            }
        } else {
            if {$RemoveContentSubTwo > 0} {
                set Redirected 1
                set NoContentabc [string map -nocase {"/content/abc/apac/" "/" "/content/abc/emea/" "/" "/content/abc/latin-america/" "/" "/content/abc/" "/"}[HTTP::uri]]
                HTTP::respond 301 location "https://[HTTP::host]/$NoContentabc"
                return
            }
        }
    }
}

This section was added on 8-18 at Andrew's request to solve a problem with axe/hybris/prod in qual-beta urls.
if {$RemoveContentSubThree > 0} {
    if {[string tolower [HTTP::uri]] starts_with "/axe/hybris/"} {
        set HybrisProtectedURI [join [lrange [split [HTTP::uri] "/"] 4 end] /]
        HTTP::respond 301 location "https://[HTTP::host]/$HybrisProtectedURI"
        return
    }
}
  • Odd, I tried to test your iRule and I am not getting any errors after I put the code in the HTTP_REQUEST event. Maybe your finger slipped while saving?