HTTP host and uri, and if there's a match, rewrite uri and redirect to new host- works if refresh
Hi All,
Truley appricate your time ...
The below iRule works only if we referesh the brower multiple times, redirection happens but HTML delays to load the page
Requirment: Redirect old host to new host and replace the URI content and redirect
http://test.com/class/results.asp?subject=
This should be redirected
https://www.results.com/school/name?subject=
I have replace replaced the URI content and redirect new URI to new HOST, works only if we refresh the brower continueosly
when HTTP_REQUEST {
log local0. "[HTTP::host][HTTP::uri]"
if { [HTTP::host] equals "test.com" && [HTTP::uri] contains "class/results.asp?subject=" } {
log local0. "[HTTP::host][HTTP::uri]"
set current_uri [HTTP::uri]
set newuri [string map {class/results.asp? school/name?} [HTTP::uri]]
log local0. "https://www.results.com$newuri"
HTTP::redirect "https://www.results.com$newuri"
}
if { [HTTP::host] equals "test.com" && [HTTP::uri] eq "/class" || [HTTP::uri] eq "/class.subject.asp" } {
HTTP::redirect "https://www.results.com"
return
}
}
Not sure of what i am doing worng in this iRule. Please advice.
Thanks,