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 rule apply without errors, however when i specify "/newapp", after the main URI, it does not redirect to www.newsite.com/home/index.html
All the help is much appreciated!
when HTTP_REQUEST {
if { ([HTTP::host] equals "www.oldsite.com") && ([string tolower [HTTP::uri]] equals "/newapp") } {
HTTP::redirect "www.newsite.com/home/index.html"
} else {
pool WEB_POOL7
}
}
Thank you in advance!!
- The_Bhattman
Nimbostratus
It could be that it's not hitting the first IF statement and simply going to pool WEB_POOL7when 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 } } }
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 } }
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 } } }
- DM_5174
Nimbostratus
Thank you CB! I will try out option 2 with a debug and see what happens. - DM_5174
Nimbostratus
I tried option 1 and 2 but does not work. Getting syntax error. Option 3 does work, however it is case senstive. So if you put "NeWaPP" or "Newapp" it does not work. It does work if you use lower case and put "newapp"... - The_Bhattman
Nimbostratus
I never took the time to validate my code. Now that I have a second look at it, I think I fixed it adding in the portion to lowercase the evalulation.when HTTP_REQUEST { if { [HTTP::host] eq "www.oldsite.com" }{ if {[string tolower [HTTP::uri]] eq "/newapp" }{ HTTP::redirect "http://www.newsite.com/home/index.html" } else { pool web_POOL7 } } }
when HTTP_REQUEST { set url [string tolower [HTTP::host][HTTP::uri]] if { $uri eq "www.oldsite.com/newapp" }{ HTTP::redirect "http://www.newsite.com/home/index.html" } else { pool web_POOL7 } }
when HTTP_REQUEST { set url [string tolower [HTTP::host][HTTP::uri]] switch -glob $url { "www.oldsite.com/newapp" { HTTP::redirect "http://www.newsite.com/home/index.html" } default { pool web_POOL7 } } }
- DM_5174
Nimbostratus
It works!!! Thank you so much CB for 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