Direct Answer
A device redirect reads the visitor's user agent and sends iPhone users to the App Store, Android users to Google Play and everyone else to a web page, all from one link. You can set it up today on your own server (examples below). In RedirHub, device routing is available on request: contact us and it can be turned on for your workspace in as little as 3 days.
| Item | Details |
|---|---|
| Goal | go.mybrand.com/app opens the right app store, or a web page on desktop |
| Redirect type | 302 Temporary, because the target depends on the device |
| Watch out for | iPads that report a Mac browser, and caches that ignore the user agent |
Set it up with Nginx#
nginxmap $http_user_agent $app_target {
default https://mybrand.com/get-the-app;
~*(iphone|ipad) https://apps.apple.com/app/id123456789;
~*android https://play.google.com/store/apps/details?id=com.mybrand.app;
}
server {
server_name go.mybrand.com;
location = /app {
add_header Vary User-Agent;
return 302 $app_target;
}
}Set it up on a web page#
If you can't change the server, a small script on the landing page can do the same. Recent iPads report a Mac browser, so check for touch support too:
javascriptconst ua = navigator.userAgent;
const isIOS = /iPhone|iPad|iPod/.test(ua) ||
(/Macintosh/.test(ua) && navigator.maxTouchPoints > 1);
if (isIOS) {
location.replace('https://apps.apple.com/app/id123456789');
} else if (/Android/i.test(ua)) {
location.replace('https://play.google.com/store/apps/details?id=com.mybrand.app');
}Common mistakes#
- Using a 301: browsers cache it, so a phone that once got the App Store keeps going there.
- Forgetting Vary: User-Agent, so a cache serves the iPhone answer to Android users.
- No fallback: desktop visitors and unknown devices need a working web page.
Device routing in RedirHub (on request)#
Branded links and QR codes in RedirHub can send each device type to its own destination once device routing is turned on for your workspace, so a printed QR code opens the right app store and you can still change the destinations later. It is set up on request and can be live in as little as 3 days.
To request it, use the contact form or email success@redirhub.com with your workspace name, the links and the destination for each device.
Need device routing on RedirHub? Tell us which links and devices you need. It can be live in as little as 3 days.
Request device routingFor store URL formats, Smart App Banners and deep links, read App Store Redirect: One Link for iPhone and Android Users.
Frequently asked questions
Device routing is available on request. Contact us through the contact form or success@redirhub.com, and it can be turned on for your workspace in as little as 3 days.
A 302. The destination depends on the device, and browsers cache 301s, which would send a phone to the same place forever.
Safari on recent iPads reports a Mac user agent. Check touch support as well, or send Mac and iPad visitors to a page with both store badges.
