Forum Discussion
HTTP:host in HTTP_RESPONSE
Just attempting to update an HTTP_RESPONSE iRule to include a HTTP:host as well as it currently covers too much of the pool it is applied to.
According to https://devcentral.f5.com/wiki/iRul...PONSE.ashx I can use HTTP::host and according to https://devcentral.f5.com/wiki/iRules.HTTP__host.ashx I can use it against HTTP_RESPONSE.
When I try and implement it though I get an error stating:
[command is not valid in current event context (HTTP_RESPONSE)] [HTTP::host]
when HTTP_RESPONSE {
if { ( [HTTP::host] equals "example.com" ) and ( [HTTP::status] == 404 ) } {
HTTP::redirect "http://example.com/error.jpg"
}
}
The reason I am checking the host is multiple host headers are on the same virtual server and I only want to apply this redirect to 404s on the one host.
Is the wiki wrong or is it my implementation?
Many thanks,
Dan
- koenning_107182NimbostratusHi Dan,
when HTTP_REQUEST { set my_host_header [HTTP::host] } when HTTP_RESPONSE { if { ( $my_host_header equals "example.com" ) and ( [HTTP::status] == 404 ) } { HTTP::redirect "http://example.com/error.jpg" } }
- hoolioCirrostratusI updated the HTTP::host wiki page to remove the response events. Thanks for pointing this error out.
- palli_69943Nimbostratus
You should probably also update https://devcentral.f5.com/wiki/iRul...PONSE.ashx
I was trying to do the same thing and wondering why it wasn't working since the docs said it should.
Recent Discussions
Related Content
* 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