Hi Brandon,
If it's just the URI in requests and response redirects, you can use something like this:
when HTTP_REQUEST {
Check the requested URI set to lowercase
switch -glob [string tolower [HTTP::uri]] {
"/newfolder/*" {
set find "newfolder"
set replace "oldfolder"
HTTP::uri [ string map -nocase "$find $replace" [HTTP::uri]]
}
}
}
when HTTP_RESPONSE {
Check if response is a redirect
if {[HTTP::is_redirect] and [HTTP::header Location] contains $find}{
Rewrite the redirect Location header value
HTTP::header replace Location [string map -nocase "$find $replace" [HTTP::header Location]]
}
Check if response payload type is text
if {[HTTP::header value Content-Type] contains "text"}{
Set the replacement strings
STREAM::expression "@$find@$replace@"
Enable the stream filter for this response only
STREAM::enable
}
}
If you need to rewrite response content as well, you can add a blank stream profile, a custom HTTP profile with response chunking set to rechunk and this iRule:
when HTTP_REQUEST {
Track whether to rewrite responses
set rewrite 0
Check the requested URI set to lowercase
switch -glob [string tolower [HTTP::uri]] {
"/newfolder/*" {
set find "newfolder"
set replace "oldfolder"
HTTP::uri [ string map -nocase "$find $replace" [HTTP::uri]]
set rewrite 1
}
}
}
when HTTP_RESPONSE {
if {$rewrite}{
Check if response is a redirect
if {[HTTP::is_redirect] and [HTTP::header Location] contains $find}{
Rewrite the redirect Location header value
HTTP::header replace Location [string map -nocase "$find $replace" [HTTP::header Location]]
}
Check if response payload type is text
if {[HTTP::header value Content-Type] contains "text"}{
Set the replacement strings
STREAM::expression "@$find@$replace@"
Enable the stream filter for this response only
STREAM::enable
}
}
}
Aaron