The way you can do this for "http://" URLs (and what I think Apple and Spotify do) this is to:
-
Register a custom URL scheme [like the other answers have shown][1].
-
Set up your HTTP URL to point to a real webpage.
-
Put a script on that page to redirect to your custom URL if is on iOS.
For example, here is a sample page which will take you to the Twitter app for a particular user or the Twitter website depending upon if you are on the web or on your iOS device.