Forum Discussion
Multiple URL redirect based on incoming URL definition
I have a need to redirect traffic coming from different URL's to another URL based on the the incoming URL string and IP address. Private addresses will redirect to one URL and all other requests will redirect to another URL. Also, this iRule will be used on multiple inbound requests for different vendors. I have the private_net Datagroup to match on for inbound IP. The Internal users referenced below will be coming from the private_net range.
Vendor 1- Inbound URL – http://qa-myaccess.com/Login/GentivaLinkTest Redirect Internal Users to – http://qa-myaccess.com/Login/GentivaLinkTest/Windows Redirect External Users to – http://qa-myaccess.com/Login/GentivaLinkTest/EmpowerID
Vendor 2- Inbound URL – http://qa-myaccess.gentiva.ghsnet.com/Login/Relias Redirect Internal Users to – http://qa-myaccess.com/Login/Relias/Windows Redirect External Users to – http://qa-myaccess.com/Login/Relias/EmpowerID
Thanks in advance.
Kirk Stanford
7 Replies
- R_Eastman_13667Historic F5 Account
Try this:
when HTTP_REQUEST { set clientURL "[HTTP::host][HTTP::uri]" if {[class match [IP::client_addr] eq "private_net"]} { if {$clientURL eq "qa-myaccess.com/Login/GentivaLinkTest" } { HTTP::redirect "http://qa-myaccess.com/Login/GentivaLinkTest/Windows" } elseif {$clientURL eq "qa-myaccess.gentiva.ghsnet.com/Login/Relias" } { HTTP::redirect "http://qa-myaccess.com/Login/Relias/Windows" } else { HTTP::redirect "http://my-access.com/something" } } else { if {$clientURL eq "qa-myaccess.com/Login/GentivaLinkTest" } { HTTP::redirect "http://qa-myaccess.com/Login/GentivaLinkTest/EmpowerID" } elseif {$clientURL eq "qa-myaccess.gentiva.ghsnet.com/Login/Relias" } { HTTP::redirect "http://qa-myaccess.com/Login/Relias/EmpowerID" } else { HTTP::redirect "http://my-access.com/something" } } } - kirk_stanford_5
Nimbostratus
Thanks so much for the quick response. I will test with this.
- kirk_stanford_5
Nimbostratus
It did not like the "ne" in the line listed below:
elseif {[class match [IP::client_addr] ne "private_net"]} {
- R_Eastman_13667Historic F5 AccountI revised the elseif to an else statement.
- kirk_stanford_5
Nimbostratus
Mucho better. Thank you again.
- kirk_stanford_5
Nimbostratus
And one more thing. If it doesn't match any of that I would like to redirect to
http://my-access.com/something
Thanks again in advance for all the help.
Kirk
- R_Eastman_13667Historic F5 AccountI updated the code snippet above.
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