Forum Discussion
jrosales2000_10
Nimbostratus
Apr 29, 2011What 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.
13 Replies
- hoolio
Cirrostratus
Maybe 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" } } } }
Aaron - jrosales2000_10
Nimbostratus
Hi 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.
Any ideas on that 2nd oem entry?
Thanks much!!
Jodie - jrosales2000_10
Nimbostratus
I'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.
Thanks again!
Jodie - jrosales2000_10
Nimbostratus
Hi Hoolio,
Is there anything in this irule that would prohibit display of images that are called via imageurl tag in an aspx page? The oddest thing - when we view the vin.aspx page through the irule (just entering in oem1.website.com), we are missing an image for a submit button (although the functionality is there, you can click on it). When i browse to that same page by directly entering the entire path to the vin.aspx page in the browser, the image for the submit button is there. Any ideas on what could be causing that? I am 99% of the way there, truly appreciate your help!
Thanks
jodie - 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?
Colin - jrosales2000_10
Nimbostratus
Yes, the exact irule (copied and pasted, just modified url):
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.ourwebsite.com" {
HTTP::uri "/landrover/vin.aspx"
}
"devsmk.jaguar.ourwebsit.com" {
HTTP::uri "/jag/vin.aspx"
}
}
}
} - Michael_Yates
Nimbostratus
I 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:
http://devsmk.landrover.ourwebsite.com/landrover/vin.aspx
http://devsmk.landrover.ourwebsite.com/jag/vin.aspx
Make sure that the traffic passes through the same Virtual Server as it would have with the iRule in place and see if you get the same behavior.
The second suggestion would be to use an HTTP Debugger like HTTPWatch or Fiddler 2 that can show you what is going on and what status code is being returned when your browser requests the missing image. - 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.
If that's the case, and the iRule is inducing some kind of wonkiness, then the only good ways to figure out where things are going awry are HTTP logging and tcpdumping.
Colin - jrosales2000_10
Nimbostratus
I will follow your troubleshooting steps today. The site definitely does work properly when the full url is entered, bypassing the irule.
This is some additional info i got from the developer today:
Here are other observations
•When navigated to http://devsmk.jaguar.mywebsite.com
oSubmit button missing
oAfter entering Vin and Dealer code, Clicking on Submit, it errors out
It is looking for vin.aspx in the root level, it needs to point to Jag/vin.aspx
•When navigated to http://devsmk.jaguar.mywebsite.com/jag/vin.aspx
oSubmit (Enter) image shows up
oAfter entering Vin and Dealer code, Clicking on “Enter”, shows next page http://devsmk.jaguar.onlymyauto.com/Jag/pre.aspx?vi=4 correctly.
Looks like we have issues navigating to Jag folder if it is not specified.
Will use Fiddler to see if i can figure out what is going on, thanks!
Jodie - jrosales2000_10
Nimbostratus
Hello 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:
OLD VERSION (button missing)
ImageUrl="~/Jag/images/btn-enter.png" OnClick="imgbtnNext_OnClick"
NEW VERSION (button appears)
ImageUrl="/Jag/images/btn-enter.png" OnClick="imgbtnNext_OnClick"
However, when clicking that button, the traffic is being routed back to the /jag/vin.aspx page that the irule is sending root traffic to instead of the /jag/pre.aspx page which is what the code is calling in this line in the code behind:
(this line of code is in the vin.aspx.cs file)
Response.Redirect("~/jag/pre.aspx?vi=" + _vinId.ToString());
We have tried the following:
Response.Redirect("/jag/pre.aspx?vi=" + _vinId.ToString());
Response.Redirect("jag/pre.aspx?vi=" + _vinId.ToString());
Response.Redirect("/pre.aspx?vi=" + _vinId.ToString());
All variations are sending the user back to the /jag/vin.aspx page that is specified in the irule. I cannot get it to route the traffic to the /jag/pre.aspx page unless i take the irule out of the picture.
If we hit the site directly from the server, the site is operating correctly, sending the user to the /jag/pre.aspx page as the code specifies (as the irule is not in play here, of course)
Any other ideas on what might be happening here? It appears to my novice eyes, that the irule is directing all traffic back to the /jag/vin.aspx no matter where the code is directing traffic.
Thank you again!
Jodie
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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
