Forum Discussion
Joe_Pipitone
Nimbostratus
Jun 18, 2009Simple redirect with query not working
I am trying to put a simple redirect in place that simply appends a subdomain if the URI is specific, basically I want to say if the URI is:
http://ourdomain.com/the/learningcenters/center/?msid=14
Then redirect to:
http://legacy.ourdomain.com/the/learningcenters/center/?msid=14
We are just adding legacy. to the url. I have put the following iRule in place, but it won't redirect - is this because of the ?msid=14 ? We have a few of these and they differ:
?msid=14
?msid=15
?msid=16
Here's my iRule:
when HTTP_REQUEST {
set h [HTTP::host]
set u [HTTP::uri]
switch -glob $h {
"http://ourdomain.com/the/learningcenters/center/?msid=14" {
HTTP::redirect "http://legacy.ourdomain.com/the/learningcenters/center/?msid=14"
}
}
}
Can anyone help?
- hwidjaja_37598
Altostratus
Try this:when HTTP_REQUEST { if { "[HTTP::host][HTTP::path]" equals "ourdomain.com/the/learningcenters/center/" } { HTTP::redirect "http://legacy.[HTTP::host][HTTP::uri]" } }
- Joe_Pipitone
Nimbostratus
Hmm....that will redirect all requests going to /the/learningcenters/center/ - we have other content that is there that we can't redirect to legacy. - hwidjaja_37598
Altostratus
Ah, I see ... What about this:when HTTP_REQUEST { if { [string match "ourdomain.com/the/learningcenters/center/?msid=*" "[HTTP::host][HTTP::uri]"] } { HTTP::redirect "http://legacy.[HTTP::host][HTTP::uri]" } }
- Joe_Pipitone
Nimbostratus
Wow that is exactly what I wanted - thanks!!!! It all makes sense now...I really appreciate your help!
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