Forum Discussion
Need to redirect URI to URI (or URL to URL) in an iRule for hosted URL to an unhosted server
I am sure this is a something super simple, but I am not entering in the right search terms. I am fairly new to the F5, but experienced in Linux.
We host dozens of servers with different hosts and URIs. Management wants to centralize all redirects on the F5 for better track of what's getting redirected where. So far, we have done this successfully with domains (hosts) to URI's:
when HTTP_REQUEST {
set host [string tolower [HTTP::host]]
if { $host contains "2014floorplan.example.com"} {
HTTP::redirect "http://expocad.example.com/vendors2014/ec/forms/attendee/indexTab.aspx"
} elseif { $host contains "fubar.example.com"} {
HTTP::redirect "http://community.shrm.org/fubar/support/"
}
This works. But what if I wanted to take a web URL/URI like: anyone who goes to **www.example.com/email** gets redirected to **www.thirdpartysite.com/mailform?customer=example_assoc&ID=8675309**
I have tried many things based on many forum posts and devcentral, but I am sure I am not searching for the right terms. Here's what I am currently trying (and it's not working)
``when HTTP_REQUEST {
set location [string tolower [HTTP::uri]]
switch -glob [HTTP::uri] {
"www.shrm.org/email" { HTTP::respond 301 Location "http://thirdparty.com/abc/" }
}
}
I am sure this can be done, but I am not understanding the syntax.
Also, is there a way to make the URL look like www.example.com/email/ so the user does not know they are in another third party site?
- shaggyNimbostratus
The [HTTP::uri] value only refers to the "/email" portion of the string. Try using [HTTP::host][HTTP::uri]
Hello,
Moreover, with -glob option, this allow you to add wildcard to your conditions :
www.exemple.com/email*
But condition ordre is vert important.
Last point, when you set a switch, you should add a défaut condition : défaut {}
- nitassEmployee
Also, is there a way to make the URL look like www.example.com/email/ so the user does not know they are in another third party site?
http redirect (HTTP::redirect or HTTP::respond 301) will cause url to be changed. if you do not want to change the browser url, you may try to rewrite uri when sending traffic to pool member using HTTP::uri command.
HTTP::uri
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