iRule to redirect URL ending with .pdf

Need iRule script for the following requirement.

any requests such as https://www.xyz.com/NR/rdonlyres/*******.pdf should be redirected to https://www.xyz.com.

here ***** means anything

when HTTP_REQUEST {
  if {[HTTP::uri] matches_glob "/NR/rdonlyres/*.pdf" } {
    HTTP::redirect "https://www.xyz.com"
  }
}

Hi Kevin, Thanks a lot for your reply. This looks pretty good. Let me test it in our Test environment, and see if this works. Thanks again.