policy to replace host value
I am trying to create a policy to replace the host in the header.
i.e is when users access myaccount.xyz.com F5 need to replace it with myaccount.abc.com and send the response to the server . And when server sends the response F5 should again replace the host to xyz.com and send to client.
I am able to get it working using an irule with wildcard but when it comes to specific url my irule is not working with the response.
when HTTP_REQUEST {
set external_hostname [HTTP::host]
set sub_hostname [substr [HTTP::host] 0 ".xy.com"]
set internal_hostname $sub_hostname.abc.com
HTTP::header replace "Host" $internal_hostname
}
when HTTP_RESPONSE {
HTTP::header replace Location [string map -nocase "$internal_hostname $external_hostname" [HTTP::header Location]]
}
Which specific host below irule is not working when i add http response, it is replacing all the hosts to myaccount.abc.com login page.
when RULE_INIT {
set ::external_hostname "myaccount.xyz.com"
set ::internal_hostname "myaccount.abc.com"
}
when HTTP_REQUEST {
HTTP::header replace "Host" $::internal_hostname
}
when HTTP_RESPONSE {
HTTP::header replace Location [string map -nocase "$::internal_hostname $::external_hostname" [HTTP::header Location]]
}