Forum Discussion

Hien_Truong's avatar
May 26, 2021

irule not redirect with wildcard.

when i try to redirect (wildcard) https://www.abc.com//index.cfm?ty=dir or https://www.abc.com//index.cfm?ty=fua, it is not redirect, do you know what happening with my irule? i appreciate your reply:

 

when HTTP_REQUEST {

 if { [HTTP::host] equals "www.abc.com" }

 {

  switch -glob [HTTP::path]

  {

            "/index.cfm?ty=dir"

     { HTTP::respond 301 Location "https://cbs.com/redir-legacy/index.cfm?ty=dir"

      }    

"/index.cfm?ty=fua"

     { HTTP::respond 301 Location "https://cbs.com/redir-legacy/index.cfm?ty=fua"

      }      

      "/"

      { HTTP::respond 301 Location "https://cbs.com/redir-legacy/"

      }

   default

    return    

}

}

}

  • ​Daniel,

    you are correct, when I change to HTTP:uri, it works. Thanks a lot for your support.

  • ​Daniel,

    you are correct, when I change to HTTP:uri, it works. Thanks a lot for your support.

  • Hi Hien,

     

    your iRule is not redirecting because HTTP:path is only index.cfm. The ty=dir is the query parameter and is in the HTTP::query command. The query is defined as the part of the request past the ? character. See below image for explanation.

    Maybe you can do the check in a different way. Use the switch statement for the HTTP::path and use a nested if / else statement for the HTTP::query. Check this out for examples: https://devcentral.f5.com/s/articles/irules-101-13-nested-conditionals

     

    KR

    Daniel

     

    • Daniel_Wolf's avatar
      Daniel_Wolf
      Icon for MVP rankMVP

      Man, I am blind. You could also use HTTP::uri which contains both, the path and the query parameter...