Forum Discussion
BuccaneerDave_2
Nimbostratus
Feb 20, 2015trouble getting redirect irule to work
Hello,
I need to have traffic from:
hostA.xyzcompanyresources.com/*
redirect to:
stageamericas.internal.xyzcompanyonline.com/pages/legacyredirection.aspx?legacyurl=hostA.xyzcompanyresou...
JRahm
Admin
Feb 20, 2015Hi BuccaneerDave. I'd start a little smaller. Some thoughts
- I don't know how that would have worked because redirect_uri variable isn't even defined (did you mean content?)
- In the age of CMP (clustered multi-processing) you should avoid global variables at all costs as it pins your virtual server traffic to one tmm instance.
- Unless you are supporting scripts/custom non-compliant tools as clients, you don't need to set the host to lower case, browsers will do this automatically per standard. Also, note that the HTTP::host command returns only the fqdn unless your virtual is on a non-standard 80/443 port, in which case it will return fqdn:
- Variables can be helpful when you are getting started to provide clarity, but given the simplicity of this effort, you really shouldn't use them.
- If you are going to have many hosts to re-map, a datagroup is a good idea, but you'll need to use the class command to extract the data. Also, I'd recommend setting the old host as the key and the new host as the value in that datagroup so you can keep all the data separate from the logic of the iRule.
- I've made some assumptions of what I think you are attempting here. Given the specifics of your example, the code below should work for you.
hope this helps sir.
when HTTP_REQUEST {
if { [HTTP::host] equals "hostA.xyzcompanyresources.com" } {
HTTP::redirect https://stageamericas.internal.xyzcompanyonline.com/pages/legacyredirection.aspx?legacyurl=[HTTP::host][HTTP::uri]
}
}
one more thing...for this url
https://devcentral.f5.com/questions/trouble-getting-redirect-irule-to-work?legacyurl=test
- HTTP::host : devcentral.f5.com
- HTTP::path : /questions/trouble-getting-redirect-irule-to-work
- HTTP::uri : /questions/trouble-getting-redirect-irule-to-work?legacyurl=test
- HTTP::query : legacyurl=test
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