I already have ready made script for this, I made it myself.
It's allow you to :
Mobile Redirect
Bot Redirect
Desktop Redirect
Count redirect (if count up or down than x then redirect)
About the "If no App Installed" it's not on the redirect side but the way your app open link with according domain.