Seems like the easiest way to do this would be to add in a second variable that keeps track of if the file that is being requested is a pdf, if I am understanding your requirements correctly. I have not tested this iRule but I believe it should look something like this.
when HTTP_REQUEST {
set asm_404_not_found 0
if { [HTTP::uri] ends_with ".pdf"} {
set pdf_requested 0
}
}
when ASM_REQUEST_BLOCKING
{
set asm_info [ASM::violation_data] Any response tweaking should only be done in blocking mode!!!
if {[string compare [ASM::status] "blocked"] == 0} {
if {[string first {VIOLATION_OBJ_DOESNT_EXIST} [lindex $asm_info 0]] != -1} {
set asm_404_not_found 1
if {[info exists pdf_requested]} {
set pdf_requested 1
} else {
ASM::disable
TCP::close
}
}
}
}
when HTTP_RESPONSE_RELEASE {
if {$asm_404_not_found == 1} {
if{$pdf_requested == 1} {
HTTP::respond 301 Location "https://www.site.com/otherpage.aspx"
} else {
HTTP::respond 301 Location "https://www.site.com/404.aspx"
}
}
}
For future reference, you can put formatted code into devcentral without an issue if you put "~~~" above and below the code you want.
Hope this helps. If you have any more questions, I am sure I can help.