Forum Discussion

Sams_88783's avatar
Sams_88783
Icon for Nimbostratus rankNimbostratus
Aug 23, 2010

Please help in converting v4.x irule to 9.x

Hello,

 

 

I tried to convert the below 4.x irule to 9.x but i am getting error.Please help me in converting the same.

 

 

if (http_host == "mydomian.com" and http_header("WL-Proxy-SSL") != "true") {

 

redirect to "https://mydomain.com/%u"

 

}

 

else if (http_host == "mydomian.com" and http_uri ends_with "/") {

 

redirect to "https://mydomian.com/index.html"

 

}

 

else if (http_host == "www.mydomianone.com" and http_uri ends_with "/") {

 

redirect to "https://www.mydomianone.com/index.html"

 

}

 

else if (http_host == "mydomianone.com" and http_uri ends_with "/") {

 

redirect to "https://mydomianone.com/index.html"

 

}

 

else if (http_host == "mydomianone.com" and http_header("WL-Proxy-SSL") != "true") {

 

redirect to "https://www.mydomianone.com/%u"

 

}

 

else if (http_host == "www.mydomianone.com" and http_header("WL-Proxy-SSL") != "true") {

 

redirect to "https://www.mydomianone.com/%u"

 

}

 

else if (http_host == "192.160.1.1") {

 

discard

 

}

 

else {

 

use pool MYDOMIAN

 

}

 

3 Replies

  • This should work. Probably not optimal, but it's the same logic

    when HTTP_REQUEST {
      if { ([HTTP::host] eq "mydomain.com") && ![HTTP::header exists "WL-Proxy-SSL"] } {
        HTTP::redirect "https://mydomain.com[HTTP::uri]"
      } elseif { ([HTTP::host] eq "mydomain.com") && ([HTTP::uri] ends_with "/") } {
        HTTP::redirect "https://mydomain.com/index.html"
      } elseif { ([HTTP::host] eq "www.mydomainone.com") && ([HTTP::uri] ends_with "/") } {
        HTTP::redirect "https://www.mydomainone.com/index.html"
      } elseif { ([HTTP::host] eq "mydomainone.com") && ([HTTP::uri] ends_with "/") } {
        HTTP::redirect "https://mydomainone.com/index.html"
      } elseif { ([HTTP::host] eq "mydomainone.com") && ![HTTP::header exists "WL-Proxy-SSL"] } {
        HTTP::redirect "https://www.mydomainone.com[HTTP::uri]"
      } elseif { ([HTTP::host] eq "www.mydomainone.com") && ![HTTP::header exists "WL-Proxy-SSL"] } {
        HTTP::redirect "https://www.mydomainone.com[HTTP::uri]"
      } elseif { [HTTP::host] eq "192.160.1.1" } {
        discard
      } else {
        pool MYDOMAIN
      }
    }

    I'm almost positive we can optimize it but I'll have to dig through it to see how the logic flows and make sure all the cases are covered.

    Hope this helps...

    -Joe