Below is a simple PHP script to detect the users device type and then redirect them to the appropriate Apple iTunes App Store or Google Play store – in my case I actually just give the Android User the APK directly:

1. Create PHP file with code on server eg. qr-redirect.php

2. Create QR to link of PHP file eg.

When a user then scans the QR they open the PHP code that detects their device and redirects them to the correct Store or File.


$iPod = stripos($_SERVER['HTTP_USER_AGENT'],"iPod");
$iPhone = stripos($_SERVER['HTTP_USER_AGENT'],"iPhone");
$iPad = stripos($_SERVER['HTTP_USER_AGENT'],"iPad");
$Android= stripos($_SERVER['HTTP_USER_AGENT'],"Android");

//check if user is using ipod, iphone or ipad...
if( $iPod || $iPhone || $iPad ){
        //we send these people to Apple Store
        header('Location:'); // <-apple store link here
}else if($Android){
        //we send these people to Android Store
        //header('Location:'); // <-android store link here
		// or we can give them the APK Directly

		$file = '/yourlocation/yourapp.apk'; //not public folder

        $fileSize = filesize($file);

         if (file_exists($file)) {
             header('Content-Description: File Transfer');
             header('Content-Type: application/');
             header('Content-Disposition: attachment; filename='.basename($file));
             header('Content-Transfer-Encoding: binary');
             header('Expires: 0');
             header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
             header('Pragma: public');
             header('Content-Length: ' . $fileSize);

		//we send all undetected to site
        header('Location: http://<a href="" data-wplink-edit="true"></a>/'); // &lt;-site link here

How to: QR Code – Multi Platform – Apple App Store and Android Google Play Store – redirect PHP
Tagged on:                                                                     

Leave a Reply

Your email address will not be published. Required fields are marked *