Forum Discussion

Tom_White_69772's avatar
Tom_White_69772
Icon for Nimbostratus rankNimbostratus
Mar 16, 2007

Redirect Irule on V4.5.10

We have created a VIP for URL "itrequest.mycompany.usa.com" but want the users to only have to enter "itrequest.mycompany.com" or "request.mycompany.com". Being first-time irule novices, what's the best way to write this iRule? We've tried this,but it's not working. How do we incorporate both URIs to the single URL?

 

 

if (http_uri == "/") {

 

redirect to "http://www.mycompany.com"

 

}

 

else {

 

redirect to "http://www.mycompany.com +httpuri

 

}

 

 

 

  • Martin_Machacek's avatar
    Martin_Machacek
    Historic F5 Account
    You need to keep in mind that the difference in your URLs is in the hostname component not the path. There are 2 possible solutions:

    1) (assuming the all 3 hostnames resolve to unique addresses) create 3 VIPs and make VIPs servicing addresses to which

    request.mycompany.com and itrequest.mycompany.com resolve redirect to itrequest.mycompany.usa.com, with following

    rule:

    
    rule redirect_to_main_url {
        redirect to "http://itrequest.mycompany.usa.com" + http_uri
    }

    2) Make request.mycompany.com and itrequest.mycompany.com aliases (CNAME) for

    itrequest.mycompany.usa.com in your DNS configuration and

    a) either configure your backend servers to ignore the Host: header in requests (i.e. no virtual hosting)

    b) using following rule on your itrequest.mycompany.usa.com VIP:

    
    rule redirect_to_main {
       if(http_host != itrequest.mycompany.usa.com) {
          redirect to "http://itrequest.mycompany.usa.com" + http_uri
       } else {
          use pool 
       }
    }