Forum Discussion

JustCooLpOOLe's avatar
JustCooLpOOLe
Icon for Cirrocumulus rankCirrocumulus
Jan 18, 2017

Append a URI to a Host via iRule

I have an iRule that is currently set up to look at the host name and uri to determine pool redirection. The customer would like that changed to append the URI /testing when the HOST is . My thought is that an HTTP redirect will just cause the request to exit out of the iRule and come back through again thus executing the iRule for a second time. I would like to just rewrite the URL to and pass it back to the associated pool.

when HTTP_REQUEST {

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

    append URI /testing
    pool TESTING_POOL

}

}

Any help would be greatly appreciated.

3 Replies

  • Hello,

     

    You can set the URI in the iRule with the command HTTP::uri,

     

    HTTP::uri "/testing"

     

    Regards,

     

  • Try this:

    if { [HTTP::host] equals "www.testing.com" } {
        HTTP::uri [HTTP::uri]testing
        pool TESTING_POOL
    }
    
  • Hi,

     

    rewrite uri only if necessary.

     

    if you rewrite /index.html to /testing/index.html, then if this document contains links to /testing/img/logo.png, then the next request will contain /testing, and then the irule will append /testing --> wrong...

     

    when rewriting path, you must look at response to be sure it does not contain the internal path in links.

     

    so, if the customer accept redirect, it will be better.