Forum Discussion
Todd_Behrens_20
Nimbostratus
Dec 14, 2017Insert JavaScript If URL path contains word
Hi Everyone, im kind of newbie when it comes to irules and was hoping someone could help me out. I'm looking to insert a javascript into the header of http response only if a certain word is in the U...
Todd_Behrens_20
Nimbostratus
Dec 14, 2017so i changed the HTTP_REQUEST varible to 'uri' but im getting the same error. here is what the code looks like now;
when HTTP_REQUEST {
Disable the stream filter by default
STREAM::disable
if {[string tolower [HTTP::uri]] contains "anakin" } {
set uri [string tolower [HTTP::uri]]
}
}
when HTTP_RESPONSE {
if { [HTTP::status] == 200 } {
if {[HTTP::header value Content-Type] contains "text"} {
set stream_find ""
set stream_find_lower ""
set stream_repl ""
set insertJscript 1
Do not allow the Javascript insertion if the pages end with the following
switch -glob $uri {
"*.ashx*" -
"*.asmx*" -
"*.axd*" -
"*.js*" {
set insertJscript 0
}
default {
if { [HTTP::payload] contains "META HTTP-EQUIV=\"Refresh\""} {
set insertJscript 0
}
}
}
if {$insertJscript == 1} {
append stream_repl $static::jscript
append stream_expression "@$stream_find@$stream_repl$stream_find@"
append stream_expression "@$stream_find_lower@$stream_repl$stream_find_lower@"
STREAM::expression $stream_expression
STREAM::enable
}
}
}
}
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