Forum Discussion
iRule append URi based on URL
I am looking to create an iRule that will append the URI based on the subdomain called.
For example - if exmaple1.test.com append /example1 if example2.test.com append /example2
I assume this is pretty basic to do but I am really lost once it comes to correct syntax etc for programming.
Any help much appreciated.
Cheers,
Isaac
4 Replies
- PeteWhite
Employee
This is quite simple - it will append the host header to the original URL. You can split up the host header with getfield eg set append [getfield [HTTP::host] "." 1]
when HTTP_REQUEST { set original_uri [HTTP::uri] set append [HTTP::host] set HTTP::uri "$original_uri/$append" } - PeteWhite
Employee
when HTTP_REQUEST { set original_uri [HTTP::uri] set append [getfield [HTTP::host] "." 1] set HTTP::uri "$original_uri/$append" } - PeteWhite
Employee
You seem to have used switch with else here, and two "when HTTP_REQUEST"s. Might be best to write this in pseudocode first and build the syntax from there. Does this match what you want?
when HTTP_REQUEST { if HTTP::host == owamail.test.com.au then set HTTP::uri to /owa[HTTP::uri] elseif HTTP::host == mobile.test.com.au then set HTTP::uri to /Microsoft-Server-ActiveSync[HTTP::uri] endif } - PeteWhite
Employee
OK, so this is the iRule that implements that pseudocode:
when HTTP_REQUEST { if { [HTTP::host] equals "owamail.test.com.au"} { set HTTP::uri /owa[HTTP::uri] } elseif { [HTTP::host] equals "mobile.test.com.au"} { set HTTP::uri /Microsoft-Server-ActiveSync[HTTP::uri] } }
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com