Forum Discussion

Sajid's avatar
Sajid
Icon for Cirrostratus rankCirrostratus
Aug 09, 2019

https redirect issue with v14

After upgrading to v14 these irules mapped to https vs not working anymore.

 

when HTTP_REQUEST {

 if { ( [string tolower [HTTP::host]] equals "www.abc.domain.com") } {

  HTTP::redirect "https://abc.domain.com[HTTP::uri]"

  }

 if { ( [string tolower [HTTP::host]] equals "www.cbe.domain.com") } {

  HTTP::respond 301 Location "https://cde.domain.com[HTTP::uri]"

 }

}

7 Replies

  • JG's avatar
    JG
    Icon for Cumulonimbus rankCumulonimbus

    Any error messages in /var/log/ltm?

  • Sajid's avatar
    Sajid
    Icon for Cirrostratus rankCirrostratus

    var/log/ltm

     

    Aug 9 14:06:00 lb_name err tmm[24290]: 01220001:3: TCL error: /Common/iRule_www_to_site <HTTP_REQUEST> - ERR_NOT_SUPPORTED (line 18) invoked from within "HTTP::host"

    • JG's avatar
      JG
      Icon for Cumulonimbus rankCumulonimbus

      Will you be able to share the full original irule here? The coee you have posted has syntax errors and does not have 18 lines.

      • Sajid's avatar
        Sajid
        Icon for Cirrostratus rankCirrostratus

        when HTTP_REQUEST {

         if { ( [string tolower [HTTP::host]] equals "www.abc.example.com") } {

          HTTP::redirect "https://abc.example.com[HTTP::uri]"

          }

         if { ( [string tolower [HTTP::host]] equals "www.def.example.com") } {

          HTTP::respond 301 Location "https://def.example.com[HTTP::uri]"

         }

          

         if { ( [string tolower [HTTP::host]] equals "www.ghi.example.com") } {

          HTTP::respond 301 Location "https://ghi.example.com[HTTP::uri]"

         }

          

         if { ( [string tolower [HTTP::host]] equals "www.jkl.example.com") } {

          HTTP::respond 301 Location "https://jkl.example.com[HTTP::uri]"

         }

         if { ( [string tolower [HTTP::host]] equals "www.mno.example.com") } {

          HTTP::respond 301 Location "https://mno.example.com[HTTP::uri]"

         }

         if { ( [string tolower [HTTP::host]] equals "www.pqr.example.com") } {

          HTTP::respond 301 Location "https://pqr.example.com[HTTP::uri]"

         }

          

         if { ( [string tolower [HTTP::host]] equals "www.stu.example.com") } {

          HTTP::respond 301 Location "https://stu.example.com[HTTP::uri]"

         }

          

         if { ( [string tolower [HTTP::host]] equals "www.vwx.example.com") } {

          HTTP::respond 301 Location "https://vwx.example.com[HTTP::uri]"

         }

          

         if { ( [string tolower [HTTP::host]] equals "www.yza.example.com") } {

          HTTP::respond 301 Location "https://yza.example.com[HTTP::uri]"

         }

          

         if { ( [string tolower [HTTP::host]] equals "www.sas.example.com") } {

          HTTP::respond 301 Location "https://sas.example.com[HTTP::uri]"

         }

          

        }

  • The first one would be very easy to replace with a Local Traffic Policy...

  • Sajid's avatar
    Sajid
    Icon for Cirrostratus rankCirrostratus

    This logic working for me.

     

    when HTTP_REQUEST {

     switch [HTTP::host] {

    "www.abc.example.com" {

    HTTP::respond 301 Location "https://abc.example.com[HTTP::uri]" 

        log local0. "Sending request to abc.example.com"}

    "www.def.example.com" {

    HTTP::respond 301 Location "https://def.example.com[HTTP::uri]"

    log local0. "Request redirect to def.example.com"}

    }

    }