If the web app is "not deployed", I'm going to go out on a limb & assume that the webserver is not serving the expected content (hence the reference to 404's while in that state).
If that's the case, all you'd need to do would be to configure an HTTP monitor against the webservers that requests a specific page and looks for a specific string on that page. The optimal monitor would request a page that runs a dynamic query against the app, which will result in the expected string NOT being returned when the app is un-deployed, thus the affected pool members would be marked DOWN and no traffic would be LB to them.
Then you'd also configure a fallback host in the HTTP profile. The value of the Fallback host field would be the fully qualified URL of the maintenance page to which you want to redirect users when all the servers are marked DOWN by this monitor.
(No iRule required. Simpler is usually better.)
HTH
/deb