Hi Jeff,
I'd try to fix the app first. If that's not an option, you can rewrite the response headers and/or content with an iRule. To rewrite the header (typically the Location header in a redirect) you can use the following rule:
when HTTP_RESPONSE {
Check if response is a redirect
if {[HTTP::is_redirect]}{
Replace http//mysite.com with nothing if it's present in the Location header value
HTTP::header replace Location [string map {http//mysite.com ""} [HTTP::header value Location]]
}
}
If you need to perform the replacement in the response content, you can add the stock stream profile and then use an iRule to configure the search/replace strings:
when HTTP_RESPONSE {
Check if response is a redirect
if {[HTTP::is_redirect]}{
Replace http//mysite.com with nothing if it's present in the Location header value
HTTP::header replace Location [string map [list http//mysite.com ""] [HTTP::header value Location]]
}
Check if response content type is text
if {[HTTP::header value "Content-Type"] starts_with "text"}{
Set the stream expression
STREAM::expression "@http//mysite.com@@"
Enable the stream filter
STREAM::enable
} else {
Response wasn't text, so disable the stream filter
STREAM::disable
}
}
If it's a typo that http//mysite.com is missing the :, you can use
http://mysite.comhttp://mysite.com as the search string and replace it with
http://mysite.com. You'd then want to use the following string map and STREAM::expression replacement strings:
Old:
HTTP::header replace Location [string map [list http//mysite.com ""] [HTTP::header value Location]]
New:
HTTP::header replace Location [string map [list
http://mysite.comhttp://mysite.com http://mysite.com] [HTTP::header value Location]]
And, for the STREAM::expression:
Old:
STREAM::expression "@http//mysite.com@@"
New:
STREAM::expression "@http://mysite.comhttp://mysite.com@http://mysite.com@"
You can check the STREAM::expression wiki page (
Click here ) for details on configuring a stream and HTTP profile for this rule.
Aaron