Forum Discussion

kirk_stanford_5's avatar
kirk_stanford_5
Icon for Nimbostratus rankNimbostratus
Oct 31, 2014

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_13667's avatar
    R_Eastman_13667
    Historic 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"
            }
        }
    }
    
  • It did not like the "ne" in the line listed below:

     

    elseif {[class match [IP::client_addr] ne "private_net"]} {

     

  • 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