PHP Redirct Based on user device (Ios , Android Or Other)

10 Aug 2015

It’s sometimes required to redirect to differnet urls based on device type.
i.e. In sharing message on some social network or any other media like whatsapp , Email or any other chat.
Here is a small script which identifies users device by inspecting useragent of their browsers.

As seen , the link is redirected to clash of clanes game based on android or ios device to pericular store.
Upload this script to server to see the effect. You can try it by spoofing useragent by User Agent Switcher.