Forum Discussion
jrosales2000_10
Apr 29, 2011Nimbostratus
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.
- Colin_Walker_12Historic F5 AccountThat's definitely interesting. That iRule shouldn't affect images loading whatsoever, so I'd definitely recommend doing some hunting to see what's going on. Michael's steps are solid, first thing is to verify that things are behaving the way you want when the iRule isn't in place.
- hooleylistCirrostratusMaybe something like this? I'm assuming you only want to rewrite the URI if the original request is for /.
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]] { "oem1.website.com" { HTTP::uri "/oem1/vin.aspx" } "oem2.website.com" { HTTP::uri "/oem2/vin.aspx" } } } }
- jrosales2000_10NimbostratusHi Hoolio, thanks for the reply. That did work, for the first OEM. The second OEM it doesn't seem to be working for, i checked for typos etc in the uri and all appears correct, but the page doesn't load correctly, it is missing images. If i browse to the landing page specified in the irule directly it does load correctly, so i'm thinking there isn't a problem with the page content itself. The pages themselves (vin.aspx) are the exact same for each OEM, just different pictures. I am also now able to browse all the way down into the folders to specific pages without a problem.
- jrosales2000_10NimbostratusI'm going to go back to the developers, if i switch the positioning of the entries (just a shot in the dark), the one still doesn't work and the other still does work, so i'm sure the irule is correct at this point.
- jrosales2000_10NimbostratusHi Hoolio,
- Colin_Walker_12Historic F5 AccountInteresting, this shouldn't affect any images that are trying to load, as it is specifically written to only apply to a path of "/", and that shouldn't include any images. Are you using the exact rule Aaron posted above? If not, could you post the iRule you're using?
- jrosales2000_10NimbostratusYes, the exact irule (copied and pasted, just modified url):
- Michael_YatesNimbostratusI think that you could approach your problem in several ways. I would suggest first that you remove the iRule from the Virtual Server and test your URL (full URL) as it would pass through the BigIP:
- jrosales2000_10NimbostratusI will follow your troubleshooting steps today. The site definitely does work properly when the full url is entered, bypassing the irule.
- jrosales2000_10NimbostratusHello again, hoping someone can stick with me while i figure this out. We did get the missing image to show up by removing a ~ from the following line of code in the vin.aspx page:
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects