I am working on a website that will automatically redirect Android users to a app page on Google Play. If the user is not using an Android device, it will redirect them to a website instead.
Current PHP code:
<?php
$Android = stripos($_SERVER['HTTP_USER_AGENT'],"Android");
$android = stripos($_SERVER['HTTP_USER_AGENT'],"android");
if ($Android || $android)
{
header("Location: market://details?id=com.CompanyName.AppName");
}
else
{
header("Location: https://CompanyName.com");
}
?>
Problem: While this code works perfectly, I am worried that some of the Android users without the installed Google Play store app wont be able to access neither of those links. Is there any way to check if Google Play is not installed to redirect those users to the website instead?
EDIT: As this is impossible to do (thanks to comments), I am looking for a solution that will detect that the URL (market://...) is invalid and will redirect the user to the website.