For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

Osama's avatar
Osama
Icon for Nimbostratus rankNimbostratus
Oct 15, 2019

iRule to Redirect url to anther url

Hi Dears,

requesting your kind support for below scenario.

 

  • I have two VS with the same IP but each one in different ports (1st one in port 80, 2nd one in port 8080)
  • I have two pools in ports 80 & 8080 associated to the above VS.
  • when the users type the full URL everything working perfectly.

the issue is that:

I have two URLs opening the same application 1st one is http://kmt and the full URL is http://kmt/livetest/livetest.exe?func=llworkspace.

so I need to the users only to write first url http://kmt, then they can redirected to the full url.

I tried below iRule but not opening .

 

when HTTP_REQUEST {

if { [HTTP::host] eq "kmt" } {

HTTP::redirect "http://kmt/livetest/livetest.exe?func=llworkspace"

}

}

may it's very simple but am new in F5 field.

thanks in advance and appreciate your urgent support.

 

4 Replies

  • Hi

    Add in some URI logic otherwise you're going to get a redirect loop. So something like...

    when HTTP_REQUEST {
    if { ([HTTP::host] eq "kmt") && ([HTTP::uri] eq "/")} {
    HTTP::redirect "http://kmt/livetest/livetest.exe?func=llworkspace"
    }
    }
    • Osama's avatar
      Osama
      Icon for Nimbostratus rankNimbostratus

      Hi iaine,

      thanks for your quick support, I applied for the VS but still not redirected.

      I wanna ask here, this iRule should be applied in which VS as I have two VS one in port 80 and second in port 8080

  • Osama's avatar
    Osama
    Icon for Nimbostratus rankNimbostratus

    Hi,

    this the correct iRule, it's working fine now.

     

    when HTTP_REQUEST {

    if { [HTTP::host] contains "kmt" and [HTTP::path] eq "/" } {

    HTTP::redirect "http://kmt/livetest/livetest.exe?func=llworkspace""

    }

    }