22-Feb-2022 17:47
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,
06-Mar-2022 08:28
Hi, I hope you already found the answer, but if not, maybe this may help;
In the IF statement, have you tried changing [HTTP::host] equals "test.com" to [HTTP::host] ends_with "test.com" ?
Certain browsers and versions automatically add "www" to the beginning of the domain name, meaning it won't match the IF statements when you are using "equals".
Hope this helps.
06-Mar-2022 20:22
Hi Alex, Thank you for your response, yes finally it worekd after adding the below lines into the iRule...i thougt of captueing the host after responded to request ans somehow it worked fo rme..
if { [HTTP::has_responded] } {
return
}
Thanks,
Nari