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

minnoce944's avatar
minnoce944
Icon for Nimbostratus rankNimbostratus
Oct 01, 2007

rewrite URI syntax

Hi there I'm new to i-rules and to the F5 product line in general. I have a VIP that needs to rewrite (not redirect) the URI based on the sub-domain.

 

 

I'm using ver BIG-IP 9.2.3 Build 34.8

 

 

Example:

 

 

http://app1.company.com --> http://application.company.com/app1.html

 

 

Example 2:

 

 

http://app2.company.com --> http://application.company.com/app2.html

 

 

Can the group provide a i-rule that can accomplish this?

 

 

Appreciate the help.

 

 

Thanks,

 

 

--minnoce944

 

 

4 Replies

  • Patrick_Chang_7's avatar
    Patrick_Chang_7
    Historic F5 Account
    Try looking at the HTTP::host and HTTP::uri entries in the iRules Wiki section. Alternatively, you could make use of F5's iRules on demand service.
  • my understanding from searching and reading thru other examples is:

     

     

    if i wanted to do a redirect:

     

     

     

    when HTTP_REQUEST {

     

    if { [HTTP::host] == "app1.company.com" } {

     

    HTTP::redirect "http://applications.company.com/app1.html"

     

    }

     

    }

     

     

    when HTTP_REQUEST {

     

    if { [HTTP::host] == "app2.company.com" } {

     

    HTTP::redirect "http://applications.company.com/app2.html"

     

    }

     

    }

     

     

    if i wanted to do a rewrite

     

     

     

     

    when HTTP_REQUEST {

     

    if { [HTTP::host] == "app1.company.com" } {

     

    HTTP::host "applications.company.com" and HTTP::uri "/app1.html"

     

    }

     

    }

     

     

    when HTTP_REQUEST {

     

    if { [HTTP::host] == "app2.company.com" } {

     

    HTTP::host "applications.company.com" and HTTP::uri "/app2.html"

     

    }

     

    }

     

     

     

    i wasn't sure if there was a HTTP::rewrite or if i had to use the replace keyword or not?

     

     

    This look right to the group?

     

     

    Let me know.

     

     

    Thanks in advance for your help.

     

     

    --minnoce944

     

  • Patrick_Chang_7's avatar
    Patrick_Chang_7
    Historic F5 Account

     

    when HTTP_REQUEST {

     

    if { [HTTP::uri] equals "/" } {

     

    switch [HTTP::host] {

     

    "app1.company.com" { HTTP::redirect "http://app1.company.com/app1.html" }

     

    "app2.company.com" { HTTP::redirect "http://app2.company.com/app1.html" }

     

    }

     

    }

     

    }

     

     

  • Thank you pchang and Joe. The redirect worked exactly as expected. Appreciate the help. Take care.

     

    --minnoce944