0

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');
}

?>
user20152015
  • 344
  • 2
  • 23
  • Why isn't it working? What errors are you getting? – Epodax Oct 23 '15 at 10:16
  • 1
    In what way is it not working. Welcome to SO. Please read [What topics can I ask about](http://stackoverflow.com/help/on-topic) and [How to ask a good question](http://stackoverflow.com/help/how-to-ask) – RiggsFolly Oct 23 '15 at 10:16
  • No errors. Only it is not redirecting =============== I will edit and post in the question – user20152015 Oct 23 '15 at 10:52

1 Answers1

0

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
}
Desmond Lua
  • 6,142
  • 4
  • 37
  • 50
  • Thanks for answering. Put your code.Now getting an error as follows - "Warning : Cannot modify header information.- headers already sent by output started at /srv/disk4/1803106/..../index.php on line ..." – user20152015 Oct 23 '15 at 11:19
  • You cannot send any output (e.g. output HTML) before calling header(...). – Desmond Lua Oct 25 '15 at 16:04