简体   繁体   English

如何使用PHP将WAP和SEMC浏览器的桌面站点重定向到移动站点

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

I am trying to redirect desktop site for Wap and SEMC broswers to mobile site using php. 我正在尝试使用php将Wap和SEMC浏览器的桌面站点重定向到移动站点。

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 Micromax X267 / R2AE SEMC-Browser / 4.0.3配置文件/MOP-2.0配置/CLDC-1.1

Please suggest. 请提出建议。

Code - 代码-

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

?>

Assuming user-agent strings of SMEC browser are like 假设SMEC浏览器的用户代理字符串类似于

CELKON.C64/R2AE SEMC-Browser/4.0.3 Profile/MIDP-2.0 Configuration/CLDC-1.1 CELKON.C64 / R2AE SEMC-Browser / 4.0.3配置文件/MIDP-2.0配置/CLDC-1.1

Micromax X088/R2AE SEMC-Browser/4.0.3 Profile/MIDP-2.0 Configuration/CLDC-1.1 Micromax X088 / R2AE SEMC-浏览器/4.0.3配置文件/MIDP-2.0配置/CLDC-1.1

You should use the following: 您应该使用以下内容:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM