Reputation: 641
How do I redirect website from different user agent? for example I want to redirect website from following user agent
from desktop: redirect to Link1
from iphone: redirect to Link2
from android: redirect to Link3
from windows(say all versions): redirect to Link4
other: redirect to Link4
How do I achieve this in php?
EDIT: actually I don't the way of using $_SERVER['HTTP_USER_AGENT'];
for user agents that i had mentioned. I have checked the answers of stackoverflow regarding this but don't know how to use that.
Upvotes: 0
Views: 2392
Reputation: 636
The following will give you the user agent of someone connecting to you.
$_SERVER['HTTP_USER_AGENT'];
You might want to consider taking a look at this. Simplest way to detect a mobile device
Upvotes: 0
Reputation: 902
You might find $_SERVER['HTTP_USER_AGENT'] useful
<?php
if(strstr($_SERVER['HTTP_USER_AGENT'],'iPhone') || strstr($_SERVER['HTTP_USER_AGENT'],'iPod')){
header('Location: http://yoursite.com/iphone');
exit();
}
?>
OR if you wanted to go by browser, you might find get_browser() useful
Upvotes: 1