Forum Discussion
iRule that routes multiple URLS to a single URL
Hi Experts
I have the following URLS from an old ECM system
\access AND \access
Post upgrade the application has been changed such that the \access is now \content.
Routing at the application level works under the firewall if connecting directly to the server but not outside the firewall via the LB.
I want to create an iRule to perform the following:
When user goes to:
(root) OR \access OR \access
ROUTE THEM TO \content
I've seen the article on how to perform this for a single URL https://devcentral.f5.com/articles/irule-recipe-1-single-url-explicit-redirect-21910 but cannot get multiple URLs to work.
Many thanks
Charis
- youssef1
Cumulonimbus
Hi,
Just for clarification, you have 2 VIP/VS?
Or only one VS that host both hostname ? if it's case you have only one application that's right?
Regards,
- ckelly45_366132
Nimbostratus
Hi Youssef;
Only one VS that host both hostnames for the two customer FQDNs
Thanks you
- Lee_Sutcliffe
Nacreous
There are a few ways you can achieve this, I've supplied a couple. Assuming when you say, 'route them to' you have your pools set up and you need to replace the host header and use the appropriate URI?
This could be one option, put your two FQDNs in a list with the one you want to ultimately use in the first entry.
when HTTP_REQUEST { set fqdnList {www.host1.com www.host2.com} if {[lsearch $fqdnList [HTTP::host]] != -1} { if {([HTTP::uri] equals "/access") || ([HTTP::uri] equals "/")} { HTTP::host [lindex $fqdnList 0] HTTP::uri "/content" } } }
This alternative method maybe easier to understand:
when HTTP_REQUEST { if {([HTTP::host] equals "www.host1.com") || ([HTTP::host] equals "www.host2.com") } { if {([HTTP::uri] equals "/access") || ([HTTP::uri] equals "/")} { HTTP::host www.host1.com HTTP::uri "/content" } } }
- youssef1
Cumulonimbus
Hi,
you can try this:
when HTTP_REQUEST { set hostname [string tolower [HTTP::host]] if { [HTTP::uri] starts_with "/access/" && [HTTP::host] equals "fqdn2.com" }{ HTTP::uri [string map {/access/ /content/} [HTTP::uri]] HTTP::header replace Host "fqdn1.com" } elseif {[HTTP::uri] equals "/access" && [HTTP::host] equals "fqdn1.com" } { HTTP::uri [string map {/access/ /content/} [HTTP::uri]] } }
Add this event if necessary if you want to manage response.
when HTTP_RESPONSE { if { [HTTP::header is_redirect] && $hostname equals "fqdn1.com"} { HTTP::header replace Location [string map -nocase "fqdn1.com fqdn2.com" [HTTP::header value Location]] } }
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