Forum Discussion
DM_5174
Nimbostratus
Jun 11, 2008HTTP to another URL redirection does not work
Hi All,
I have the following i-rule that does not work and I have no clue what the problem is, and if its with the irule or the LTM (virtual server profile etc...)
The ru...
The_Bhattman
Nimbostratus
Jun 12, 2008It could be that it's not hitting the first IF statement and simply going to pool WEB_POOL7
In that case you might want to add the following debug statement to verify.
Add the following before HTTP::redirect statement
when HTTP_REQUEST {
if { ([HTTP::host] equals "www.oldsite.com") && ([string tolower [HTTP::uri]] equals "/newapp") } {
log local0. "The url is [HTTP::host][HTTP::uri]"
HTTP::redirect "www.newsite.com/home/index.html"
} else {
pool WEB_POOL7
log local0. "This Pool WEB_PPOL7 was selected "
}
}
This will log the a message in /var/log/ltm file and when you run it will you know which part of the iRule it was executed. If you see the second message then you know it's not hitting the IF statement.
OR
you can rewrite the entire iRule in 3 other ways(...actually there is a 4th way but I think I overkilled this one 🙂 ...)
Other Way 1
when HTTP_REQUEST {
if { [HTTP::host] = "www.oldsite.com" } {
if {[HTTP::uri] = "/newapp" } { HTTP::redirect "http://www.newsite.com/home/index.html" }
} else {
pool WEB_POOL7
}
}
}
Other Way 2
when HTTP_REQUEST {
set url [HTTP::host][HTTP::uri]
if { $url = "www.oldsite.com/newapp" } {
HTTP::redirect "http://www.newsite.com/home/index.html"
} else {
pool WEB_POOL7
}
}
Other Way 3
when HTTP_REQUEST {
set url [HTTP::host][HTTP::uri]
switch -glob $url {
"www.oldsite.com/newapp" { HTTP::redirect "http://www.newsite.com/home/index.html" }
default { pool WEB_POOL7 }
}
}
Hope this helps
CB
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