Forum Discussion

jrosales2000_10's avatar
jrosales2000_10
Icon for Nimbostratus rankNimbostratus
Apr 29, 2011

What did i do wrong with this irule for redirection based on url

Hi, i am trying to accomplish the following (we are running LTM 1600's version 9.4.6):

 

 

If a user enters url: oem1.website.com they are routed to oem1.website.com/oem1/vin.aspx

 

 

If a user enters url: oem2.website.com they are routed to oem2.website.com/oem2/vin.aspx

 

 

There is one Virtual Server (and one website in IIS) that serves the content for both of these oem's, however, based on the url entered, i want them each to go to their correct subfolder that contains pages that are skinned for their particular oem.

 

 

I have tried using the following irule:

 

 

when HTTP_REQUEST {

 

if {[string tolower [HTTP::host]] eq "oem1.website.com" } {

 

HTTP::uri "/oem1/vin.aspx"

 

}

 

if {[string tolower [HTTP::host]] eq "oem2.website.com" } {

 

HTTP::uri "/oem2/vin.aspx"

 

}

 

}

 

 

The problem i am having is that no matter what the user enters for a complete url (ie - oem1.website.com/oem1/images/image.jpg) it is routing the user back to that /oem1/vin.aspx.

 

 

On my initial shot at the irule, i wanted to have the irule work for all environments, (dev.oem1.website.com, qatest.oem1.website.com, etc), so in place of the EQUALS above, i used CONTAINS. I figured this is what was causing all traffic containing the url to be routed to the vin.aspx page. I thought maybe changing it to EQUALS would allow the rest of the traffic to flow appropriately, but it isn't working, so i didn't do something correctly.

 

 

I don't use irules too much, (i gleaned what i do know from these forums) :), any help would be appreciated! If i am off base on my approach, and you think another method would work better, i am open to suggestions!

 

 

Thanks!

 

Jodie

 

 

Edited to change equals to eq and to note that it is just one virtual server.
  • Try this modification with some logging enabled and let us know what the results are.

    This should log the incoming [HTTP::host] and [HTTP::uri] at the beginning of the iRule so that you know what it starts with. From there you should know if it qualifies for the first if statement.

    The second is just prior to the [HTTP::uri] compare.

    
    when HTTP_REQUEST {
    log local0. "Incoming URL - HOST:[HTTP::host] URI:[HTTP::uri] 
     Check if the request is for the root document
    if {[HTTP::path] eq "/" } {
    switch [string tolower [HTTP::host]] {
    "devsmk.landrover.ourwebsite.com" { HTTP::uri "/landrover/vin.aspx" }
    "devsmk.jaguar.ourwebsit.com" { HTTP::uri "/jag/vin.aspx" }
    }
    }
    switch -glob [ string tolower [HTTP::uri]] {
    log local0. "URI Compare - URI:[HTTP::uri]"
    "/jag*" { pool pool.containing.jag.files }
    }
    }
    
  • Hi, i wanted to follow up with a resolution on this issue (they are still qa'ing, but an initial smoketest looks good).

     

     

    To fix, i removed the /vin.aspx out of the HTTP::uri statement, and setup IIS to handle the default document for the /jag and the /landrover folders. This allowed me to route users to the correct subfolder based on url, and lets IIS manage the default document.

     

     

    Thanks for sticking with me on this, i truly appreciate it!!

     

     

    Here is my final irule:

     

     

     

    when HTTP_REQUEST {

     

     

    Check if the request is for the root document

     

    if {[HTTP::path] eq "/" }{

     

     

    Check the Host header

     

    switch [string tolower [HTTP::host]] {

     

    "devsmk.landrover.mywebsite.com" {

     

    HTTP::uri "/landrover"

     

    }

     

    "devsmk.jaguar.mywebsite.com" {

     

    HTTP::uri "/jag"

     

    }

     

    }

     

    }

     

    }
  • Glad we could help you get your problem resolved.

     

     

    Let us know if you need anything else :-)