Help! Redirect Users Who Have Mobile Devices

CashDummy

Regular Member
Joined
Oct 3, 2007
Messages
233
Reaction score
106
Is there a code I can use to send people who go to my site using a mobile device to a different link?
 
Probably start with some of these, especially the third link.

https://css-tricks.com/snippets/javascript/redirect-mobile-devices/

http://www.inmotionhosting.com/support/website/redirects/mobile-redirect

https://www.google.com/search?q=Redirect+Users+Who+Have+Mobile+Devices&oq=Redirect+Users+Who+Have+Mobile+Devices&aqs=chrome..69i57j69i60&sourceid=chrome&ie=UTF-8
 
I looked on google before I asked here and after many clicks none of appeared to work so I came up with this.
Code:
<meta HTTP-EQUIV="REFRESH" content="0; url=https://Mysite.com=">
<script type="text/javascript">
<!--
if (screen.width <= 1000) {
window.location = "https://MysiteForMobile.com";
}
//-->
</script>

works like a charm!

Hope this will help anyone else
 
Thanks for the code. I used to achieve this using the tracker Voluum back in the day.
 
Javascript method is not reliable. use php snippet instead.
code is mentioned below
PHP:
<?php
require_once 'Mobile_Detect.php';
$detect = new Mobile_Detect;

if($detect->isMobile()) {
   header('Location: http://mobile.example1.com/'); // url of your mobile site or any different link
   exit;
}

the content of Mobile_Detect.php is here https://github.com/serbanghita/Mobile-Detect/blob/master/Mobile_Detect.php

This is very fast as compared to javascript method
 
Back
Top