Este sitio web utiliza cookies para realizar análisis y mediciones de tus visitas. [ Acepto ] [ Más información aquí ].

How to Detect Mobile Phones in your Website

To detect visits from mobile phones with PHP, download the file Mobile_Detect.php, and then add this condition to your website:

include 'Mobile_Detect.php';

$detect = new Mobile_Detect;

if ($detect->isMobile())

{

include 'mobile.html';

} else {

include 'computer.html';

}

In this case, tablet visitors will see the file mobile.html, and PC visitors will see computer.html. If you want to know how to detect tablet users, visit "How to Detect Tablets in your Website".

You can also redirect mobile and tablets users to a specific folder or a specific subdomain with these .htacess codes:

Code to redirect mobile users to a folder:

RewriteEngine on

RewriteCond %{HTTP_USER_AGENT} Android|Blackberry|iPad|iPhone|ipod|

iemobile|opera\ mobile|palmos|webos|googlebot-mobile

RewriteCond %{REQUEST_URI} !^/Folder Name/

RewriteRule .* /Folder Name/ [R]

Code to redirect mobile users to a subdomain:

RewriteEngine on

RewriteCond %{HTTP_USER_AGENT} Android|Blackberry|iPad|iPhone|ipod|

iemobile|opera\ mobile|palmos|webos|googlebot-mobile

RewriteRule .* http://iphone.example.com/ [R]

Añadir comentario