Forum Discussion

joxonu_175315's avatar
joxonu_175315
Icon for Nimbostratus rankNimbostratus
Sep 28, 2015

Need help with iRule using iFiles

Hey all, I have an iRule that calles iFiles for a local maintenance page but only seems to work at the root of the URL. ex. www.example.com/ -> works, renders html text and graphic. www.example....
  • Brad_Parker_139's avatar
    Sep 28, 2015

    I'm guessing you are trying to match the file no matter the path. If that's the case you need a glob added to the switch and "*" added to your jpg and gif uris:

    when HTTP_REQUEST priority 10 { 
        switch -glob [HTTP::uri] {
            "*/down.jpg" { 
                HTTP::respond 200 content [ifile get down.jpg] "Content-Type" "image/png" "Connection" "Close"
                event HTTP_REQUEST disable
            }
            "*/poweredby.gif" { 
                HTTP::respond 200 content [ifile get poweredby.gif] "Content-Type" "text/css" "Connection" "Close"
                event HTTP_REQUEST disable
            }
            default {   
                if { ( [HTTP::uri] starts_with "/"  ) } {
                    HTTP::respond 200 content [ifile get down.html] "Content-Type" "text/html" "Connection" "Close"
                    event HTTP_REQUEST disable
                }
            }
        }
    }