Forum Discussion
Dunleap_21354
Nimbostratus
Mar 28, 2008Rewriting HTTP host name
I'm trying to write my first irule. I need to take the client request:
when HTTP_REQUEST {
and replace the HTTP host name H23.abc.com with D2.xyz.com and pass it on to the p...
Mar 28, 2008
If you want to replace the host value (http://host/uri), then you won't want the Location header. The Location header is a response header that used for 301 and 302 based redirects. You'll want to use the basic "Host" header. This should work for you.
when HTTP_REQUEST {
if { [HTTP::host] equals "H23.abc.com" } {
HTTP::header replace "Host" "D2.xyz.com"
}
}
Or, if you only have the virtual on the H23.abc.com domain, then you can omit the if and just do the assignment.
Unfortunately, there isn't a version of the HTTP::host command that assigns the value so you'll have to do it with the "HTTP::header replace" command.
As for your question about the string map command, your supplied example will replace all values of "H23.abc.com" with "D2.xyz.com" in the HTTP Location response header and assign it to the Location header. Make sense?
-Joe
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