How to redirect desktop site for wap and SEMC browser to mobile site using php

171 views Asked by At

I am trying to redirect desktop site for Wap and SEMC broswers to mobile site using php.

I am using this code but it is not working.

Edit -

No errors are coming. Only it is not redirecting.

User agent strings are like this -

Micromax X267/R2AE SEMC-Browser/4.0.3 Profile/MOP-2.0 Configuration/CLDC-1.1

Please suggest.

Code -

<?php
$useragent=$_SERVER['HTTP_USER_AGENT'];
if(strpos('SEMC-Browser/i',$useragent))
{
header('Location: http://m.yourmobilesite.com');
}

?>
1

There are 1 answers

2
Desmond Lua On

Assuming user-agent strings of SMEC browser are like

CELKON.C64/R2AE SEMC-Browser/4.0.3 Profile/MIDP-2.0 Configuration/CLDC-1.1

Micromax X088/R2AE SEMC-Browser/4.0.3 Profile/MIDP-2.0 Configuration/CLDC-1.1

You should use the following:

if (strpos($useragent, 'SEMC-Browser/') !== false) {
    // redirect
}