Forum Discussion

Habib_Ulla_Khan's avatar
Habib_Ulla_Khan
Icon for Nimbostratus rankNimbostratus
Dec 06, 2017

Irule giving error : Operation not supported. Multiple redirect/respond invocations not allowed

Hi All,

 

Below is the url i have used in virtual server and i am getting error as below. Need some advice to make sure if we can write same irule in different way or how can we rectify these error.

 

TCL error: /Common/web-zwcom-http-irule - Operation not supported. Multiple redirect/respond invocations not allowed (line 18) invoked from within "HTTP::redirect "https://[HTTP::host][HTTP::uri]"" ("/en-/" arm line 2) invoked from within "switch -glob [string tolower [HTTP::uri]] { "/en/" - "/content/" - "/apps/" - "/etc/" - "/qr/" - "/libs/" - "/bin/*" - ..."

 

Code
when HTTP_REQUEST { 
if {([HTTP::uri] contains "credit-card-verification.page")||([HTTP::uri] contains "facebook.page")}{
HTTP::redirect "https://[HTTP::host][HTTP::uri]"
}
if {([string tolower [HTTP::uri]] starts_with "/ar/") and ([string tolower [HTTP::uri]] contains 
".page") }{
return
}
if { (([HTTP::host] contains "zmiles.com") or ([HTTP::host] contains "www.zmiles.com")) } {
HTTP::redirect "https://www.zways.com/en/Primary-Club.html"
}
if { (([HTTP::host] equals "zways.ch") or ([HTTP::host] equals "www.zways.ch")) } {
HTTP::respond 301 Location "http://www.zways.com/ch"
}
if { (([HTTP::host] equals "zways.qa") or ([HTTP::host] equals "www.zways.qa")) } {
HTTP::respond 301 Location "http://www.zways.com/qa"
}
if {[string tolower [HTTP::host]] eq "zways.com"}{
switch -glob [string tolower [HTTP::uri]] {
"/en/*" -
"/content/*" -
"/apps/*" -
"/etc/*" -
"/zr/*" -
"/libs/*" -
"/bin/*" -
"/en-*/*" -
"/ar-*/" -
"/ar/*" {
HTTP::respond 301 Location "https://www.[HTTP::host][HTTP::uri]"
}
}
}
if { ([string tolower [HTTP::host]] equals "www.zways.com") || ([string tolower [HTTP::host]] equals 
 "originwww.zways.com") || ([string tolower [HTTP::host]] equals "zways.com") } {
  switch -glob [string tolower [HTTP::uri]] {
  "/en/*" -
  "/content/*" -
  "/apps/*" -
  "/etc/*"  -
   "/zr/*"   -
   "/libs/*" -
   "/bin/*"  -
   "/en-*/*" {
  HTTP::redirect "https://[HTTP::host][HTTP::uri]"
 }
"/ar-*/*" -
"/ar/*" {
HTTP::respond 301 Location "https://[HTTP::host]/ar/homepage.html"
}
"/en-ae/*" -    
"/en-sa/*" -    
"/en-bh/*" -
"/en-eg/*" -
"/content/global/aa/*" { 
HTTP::redirect "https://[HTTP::host]/en/homepage.html" 
  }
"*-rain*" -
"*-dam*" -
"*-jed*" -
"*-gas*" -
"*-alex*" -
"*-shar*" -
"*-ras*" -
"*-tai*" -
"*-abh*" -
"*-medi*" -
"*-hof*" -
"*-alex*" -
"*-lux*" -
"*-yan*" -
"*-dub*" -
"*-egt*" -
"*-united-*" -
"*-sauai*" -
"*-car*" -
"*-riya*" -
"*-ababi*" -
"*-dub*"   {
set zrcom_uri [substr "[string tolower [HTTP::uri]]" 1 "/"]
    if { ($zrcom_uri contains "-") || ($zrcom_uri equals "en") || ($zrcom_uri equals "ar") }{
        log local0. "NEW: $zrcom_uri"
        HTTP::redirect "https://[HTTP::host]/$zrcom_uri/discover.html"
} else {
        set old_zrcom_uri [substr "[string tolower [HTTP::uri]]" 1 5]
        log local0. "OLD: $old_zrcom_uri"
        HTTP::redirect "http://[HTTP::host]/$old_zrcom_uri/destinations.page"
       }
       }
       }
       }
       }
  • If I'm no mistaken you need to use "elseif" no to redirect twice ;).

    when HTTP_REQUEST { 
    if {([HTTP::uri] contains "credit-card-verification.page")||([HTTP::uri] contains "facebook.page")} {
        HTTP::redirect "https://[HTTP::host][HTTP::uri]"
    } elseif {([string tolower [HTTP::uri]] starts_with "/ar/") and ([string tolower [HTTP::uri]] contains ".page") } {
        return
    } elseif { (([HTTP::host] contains "zmiles.com") or ([HTTP::host] contains "www.zmiles.com")) } {
        HTTP::redirect "https://www.zways.com/en/Primary-Club.html"
    } elseif { (([HTTP::host] equals "zways.ch") or ([HTTP::host] equals "www.zways.ch")) } {
        HTTP::respond 301 Location "http://www.zways.com/ch"
    } elseif { (([HTTP::host] equals "zways.qa") or ([HTTP::host] equals "www.zways.qa")) } {
        HTTP::respond 301 Location "http://www.zways.com/qa"
    } elseif {[string tolower [HTTP::host]] eq "zways.com"}{
        switch -glob [string tolower [HTTP::uri]] {
            "/en/*" -
            "/content/*" -
            "/apps/*" -
            "/etc/*" -
            "/zr/*" -
            "/libs/*" -
            "/bin/*" -
            "/en-*/*" -
            "/ar-*/" -
            "/ar/*" {
                HTTP::respond 301 Location "https://www.[HTTP::host][HTTP::uri]"
            }
        }
    
    } elseif { ([string tolower [HTTP::host]] equals "www.zways.com") || ([string tolower [HTTP::host]] equals "originwww.zways.com") || ([string tolower [HTTP::host]] equals "zways.com") } {
        switch -glob [string tolower [HTTP::uri]] {
        "/en/*" -
        "/content/*" -
        "/apps/*" -
        "/etc/*"  -
        "/zr/*"   -
        "/libs/*" -
        "/bin/*"  -
        "/en-*/*" {
            HTTP::redirect "https://[HTTP::host][HTTP::uri]"
        }
        "/ar-*/*" -
        "/ar/*" {
            HTTP::respond 301 Location "https://[HTTP::host]/ar/homepage.html"
        }
        "/en-ae/*" -    
        "/en-sa/*" -    
        "/en-bh/*" -
        "/en-eg/*" -
        "/content/global/aa/*" { 
            HTTP::redirect "https://[HTTP::host]/en/homepage.html" 
        }
        "*-rain*" -
        "*-dam*" -
        "*-jed*" -
        "*-gas*" -
        "*-alex*" -
        "*-shar*" -
        "*-ras*" -
        "*-tai*" -
        "*-abh*" -
        "*-medi*" -
        "*-hof*" -
        "*-alex*" -
        "*-lux*" -
        "*-yan*" -
        "*-dub*" -
        "*-egt*" -
        "*-united-*" -
        "*-sauai*" -
        "*-car*" -
        "*-riya*" -
        "*-ababi*" -
        "*-dub*"   {
            set zrcom_uri [substr "[string tolower [HTTP::uri]]" 1 "/"]
            if { ($zrcom_uri contains "-") || ($zrcom_uri equals "en") || ($zrcom_uri equals "ar") } {
                log local0. "NEW: $zrcom_uri"
                HTTP::redirect "https://[HTTP::host]/$zrcom_uri/discover.html"
                }
                else {
                    set old_zrcom_uri [substr "[string tolower [HTTP::uri]]" 1 5]
                    log local0. "OLD: $old_zrcom_uri"
                    HTTP::redirect "http://[HTTP::host]/$old_zrcom_uri/destinations.page"
                }
            }
        }
    }
    

    }

    • Habib_Ulla_Khan's avatar
      Habib_Ulla_Khan
      Icon for Nimbostratus rankNimbostratus

      I get redirection but uri is reoccuring /en/homepage.htmlhomepage.htmlhomepage.htmlhomepage.htmlhomepage.htmlhomepage.htmlhomepage.htmlhomepage.htmlhomepage.htmlhomepage.htmlhomepage.htmlhomepage.htmlhomepage.htmlhomepage.htmlhomepage.htmlhomepage.htmlhomepage.htmlhomepage.htmlhomepage.htmlhomepage.html