Forum Discussion
Multiple URL redirect based on incoming URL definition...
I posted this last week however the answer provided did not work. I am looking for other suggestions. Thanks in advance to all that answer.
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
All else go to http://qa-myaccess.com/empowerID
Thanks in advance.
Kirk Stanford
7 Replies
- shaggy
Nimbostratus
can you provide a link to the previous post? otherwise you may get the same advice a second time. also, why didn't the previous solution work? did it not work due to syntax errors or because of logic? - Hannes_Rapp_162
Nacreous
Try the solution below.
Additionally, my recommendation would be to uncomment the event disable statements, if there are other iRules attached to VS which are invoking redirects/responses. (Multiple invocations of redirect/response statements are not permitted and will result in a TCL error)
when HTTP_REQUEST { set VISITOR "external" if { [class match [IP::client_addr] equals "data_ip_internal_networks"] } { set VISITOR "internal" } if {$VISITOR == "external"} { switch [HTTP::host][HTTP::uri] { "qa-myaccess.com/Login/GentivaLinkTest" { HTTP::respond 301 location " event disable } "qa-myaccess.gentiva.ghsnet.com/Login/Relias" { HTTP::respond 301 location " event disable } default { HTTP::respond 301 location ""> event disable } } } elseif {$VISITOR == "internal"} { switch [HTTP::host][HTTP::uri] { "qa-myaccess.com/Login/GentivaLinkTest" { HTTP::respond 301 location " event disable } "qa-myaccess.gentiva.ghsnet.com/Login/Relias" { HTTP::respond 301 location " event disable } default { HTTP::respond 301 location ""> event disable } } } }
- Hannes_Rapp_162
Nacreous
Note, this retarded encoding tool appears interpret hyperlinks in its own format regardless of code block that was used. Can't find a way to correct it. For both SWITCH statements, the correct code for "default" section would be as follows: default { HTTP::respond 301 location "http://qa-myaccess.com/empowerID" event disable }
- Hannes_Rapp
Nimbostratus
Try the solution below.
Additionally, my recommendation would be to uncomment the event disable statements, if there are other iRules attached to VS which are invoking redirects/responses. (Multiple invocations of redirect/response statements are not permitted and will result in a TCL error)
when HTTP_REQUEST { set VISITOR "external" if { [class match [IP::client_addr] equals "data_ip_internal_networks"] } { set VISITOR "internal" } if {$VISITOR == "external"} { switch [HTTP::host][HTTP::uri] { "qa-myaccess.com/Login/GentivaLinkTest" { HTTP::respond 301 location " event disable } "qa-myaccess.gentiva.ghsnet.com/Login/Relias" { HTTP::respond 301 location " event disable } default { HTTP::respond 301 location ""> event disable } } } elseif {$VISITOR == "internal"} { switch [HTTP::host][HTTP::uri] { "qa-myaccess.com/Login/GentivaLinkTest" { HTTP::respond 301 location " event disable } "qa-myaccess.gentiva.ghsnet.com/Login/Relias" { HTTP::respond 301 location " event disable } default { HTTP::respond 301 location ""> event disable } } } }
- Hannes_Rapp
Nimbostratus
Note, this retarded encoding tool appears interpret hyperlinks in its own format regardless of code block that was used. Can't find a way to correct it. For both SWITCH statements, the correct code for "default" section would be as follows: default { HTTP::respond 301 location "http://qa-myaccess.com/empowerID" event disable }
- R_Eastman_13667Historic F5 AccountWow, you deleted the previous solution? The below solution seems to be about the same as the previous one.
- kirk_stanford_5
Nimbostratus
This worked great!!!! Thanks so much. I really appreciate your help.
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