Forum Discussion
aandreyy_293459
Nimbostratus
Jul 25, 2017iRule for redirecting to different uri
iRule for redirecting to different uri
i have problem like have redirection in iRule
when HTTP_REQUEST "/url" use pool POOL
now i need have
"/newurl" use pool NEWPOOL but need forward ...
Jad_Tabbara__J1
Cirrostratus
Jul 26, 2017Hello Aandrey,
I read you comments, I think that what you need to do is to rewrite all response coming from Newpool containing URL that points to /url.
You need to add a "SREAM PROFILE" to your VS and use the following irule example :
when HTTP_REQUEST {
set rewrite "0"
set host [string tolower [HTTP::host]]
if { [ string tolower [HTTP::uri]] starts_with "/url" } {
pool oldpool
} elseif { [string tolower [HTTP::uri]] starts_with "/newurl" } {
set rewrite "1"
STREAM::disable
HTTP::header remove "Accept-Encoding"
pool NewPool
}
}
when HTTP_RESPONSE {
Make rewrite only for responses coming from pool NewPool
if { rewrite eq "1" } {
if {[HTTP::header exists Location] } {
if { [string tolower [HTTP::header Location]] contains "/url/"} {
log local0. "Old Location is: [HTTP::header Location]"
HTTP::header replace Location [string map {"/url/" "/newurl/"} [HTTP::header Location]]
log local0. "New Location is: [HTTP::header Location]"
}
}
if {[HTTP::header value Content-Type] contains "text" || [HTTP::header value Content-Type] contains "xml" }{
Will replace all links in text or xml "Content-Type" that contains yourapp.doamin.com/url by yourapp.doamin.com/newurl
STREAM::expression "@$host/url@$host/newurl@"
STREAM::enable
}
}
}
Hope it helps
Regards
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