Forum Discussion

kirk_stanford_5's avatar
kirk_stanford_5
Icon for Nimbostratus rankNimbostratus
Nov 03, 2014

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's avatar
    shaggy
    Icon for Nimbostratus rankNimbostratus
    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?
  • 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's avatar
      Hannes_Rapp_162
      Icon for Nacreous rankNacreous
      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 }
  • 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's avatar
      Hannes_Rapp
      Icon for Nimbostratus rankNimbostratus
      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_13667's avatar
    R_Eastman_13667
    Historic F5 Account
    Wow, you deleted the previous solution? The below solution seems to be about the same as the previous one.