Forum Discussion

JemW_329006's avatar
JemW_329006
Icon for Nimbostratus rankNimbostratus
Apr 03, 2019

irule - basic insertion of text to url

An irule is used to capture requests to our https domains and redirect appropriately. All entries in this irule have been simple redirects from external address to the internal server on the same internal uri, such as to server/A.

We have a new website that needs publishing on a different url to that on itself. This means the new url needs redirecting from "" to //server/script/abc/.

Is there a way to do this without branching off into variables?An extract of our irule follows, looking forward to your help!

(BigIP v13.1.1)

:

set my_uri [ string tolower [HTTP::uri]]

...

 if { [HTTP::uri] starts_with "xyz"} {
  pool xyz
} elseif { $my_uri starts_with "x"} {
  pool Pool_x

...

} elseif { $my_uri starts_with "/abc"} {
  
  pool Pool_ABC

...

  • Hi JemW,

    a very minimalistic iRule will look like below...

    when HTTP_REQUEST {
        set low_uri [string tolower [HTTP::uri]]
        if { $low_uri starts_with "/xyz"} then {
            pool Pool_xyz
        } elseif { $low_uri starts_with "/x"} then {
            pool Pool_x
        } elseif { $low_uri starts_with "/abc"} then {
            HTTP::path "/scripts[HTTP::path]"
            pool Pool_abc
        }
    }
    

    Note: Depending on how the web application is made, you may need to modify the HTTP responses too. If the application references

    /scripts/abc
    in its HTML/CSS/etc., you will need to adjust those references to
    /abc
    before sending the response to your clients. Be warned, it will be time consuming to adjust complex applications...

    Cheers, Kai