Forum Discussion

Christian_Greyl's avatar
Christian_Greyl
Icon for Nimbostratus rankNimbostratus
Dec 04, 2015

One VIP with two URLs redirecting to two URIs

Hi

 

I'm new with Irules so there's probably something small amiss here. I want the Irule to detect the difference between these two URLs and redirect it accordingly to the correct URL and URI.

 

smartit.xyz.com -> https://smartit.xyz.com/ux/smart-it// myit.xyz.com -> https://myit.xyz.com/ux/myitapp//

 

I also have a VIP on port 80 that redirects it to become HTTPS.

 

Any ideas ?

 

when HTTP_REQUEST { if { [HTTP::host] equals "smartit.xyz.com" and {[HTTP::uri] equals "/" }} { HTTP::redirect "https://smartit.xyz.com/ux/smart-it//" } if { [HTTP::host] equals "myit.xyz.com" and {[HTTP::uri] equals "/" }} { HTTP::redirect "https://myit.xyz.com/ux/myitapp//" }

 

}

 

Port 80 VIP

 

when HTTP_REQUEST { HTTP::redirect "https://[HTTP::host][HTTP::uri]" }

 

2 Replies

  • Hi Christian,

    you can try the following, please:
    when HTTP_REQUEST {
        if { ([string tolower [HTTP::host]] equals "smartit.xyz.com") and ([HTTP::uri] equals "/") } {
            HTTP::redirect "https://smartit.xyz.com/ux/smart-it//"
            return
        } 
        if { ([string tolower [HTTP::host]] equals "myit.xyz.com") and ([HTTP::uri] equals "/") } {
            HTTP::redirect "https://myit.xyz.com/ux/myitapp//"
            return
        }
    }
    

    Thanks, Stephan

  • Thanks you for the reply 😄 . Shortly after posting this I got it sorted by doing the following.

    when HTTP_REQUEST { 
    if { [HTTP::host] equals "smartit.xyz.com" and [HTTP::uri] equals "/" }{ 
        HTTP::redirect "[https://smartit.xyz.com/ux/smart-it//](https://smartit.xyz.com/ux/smart-it//)" 
      } 
    if { [HTTP::host] equals "myit.xyz.com" and [HTTP::uri] equals "/" } { 
        HTTP::redirect "[https://myit.xyz.com/ux/myitapp//](https://myit.xyz.com/ux/myitapp//)" 
      } 
    
    }