Forum Discussion
Yugandhar
Nimbostratus
Mar 14, 2019To replace Hostname in HTTP Request and HTTP Response
Hi,
Can we use the following iRule to replace the hostname in the HTTP Request and HTTP Response.
when HTTP_REQUEST{
if { [string tolower [HTTP::host] ] equals "myabc.wxy.com" }{
HTTP::replace replace Host "replace.wxy.com"
}
}
when HTTP_RESPONSE{
if { [string tolower [HTTP::host] ] equals "replace.wxy.com" }{
HTTP::header replace "myabc.wxy.com"
}
}
Thanks,
Yugandhar.
- Rico
Cirrus
This should work
when HTTP_REQUEST{ if { [string tolower [HTTP::host] ] equals "myabc.wxy.com" } { HTTP::header replace Host "replace.wxy.com" } } when HTTP_RESPONSE { if { [string tolower [HTTP::host] ] equals "replace.wxy.com" }{ HTTP::header replace Host "myabc.wxy.com" } }
Try using a rewrite profile instead of an iRule:
create ltm profile rewrite REWRITE rewrite-mode uri-translation uri-rules add { myabc.wxy.com { type request client { scheme http host myabc.wxy.com path / } server { scheme http host replace.wxy.com path / } } }
modify ltm virtual profiles add { REWRITE }
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