How to redirect page to pc and wap

Started on the old forum in July 2009 · view the original in the archive · old links redirect here

7 replies · 601 views · started 17 years ago · 1 min read

5 participants
bijaybd Developer · 178 posts #1

hey guys i search the forum tried a lot of sources but failed.

i need the code like: if a user visit the site from internet explorer it will redirect to web page.if a user visit the site from mobile phone then it will redirect to wml page.if a user visit the site from opera using mobile it will also redirect to the wml page.and if a user visit the site using firefox also have addon for wml support will also go to the wml page otherwise if don't have then pc.and all the browser using pc do not support wml will be directed to the pc web page.and if the browser support wml it will redirect to wml page.

opticalpigion Lead · 593 posts #2

bijaybd wrote: hey guys i search the forum tried a lot of sources but failed.

i need the code like: if a user visit the site from internet explorer it will redirect to web page.if a user visit the site from mobile phone then it will redirect to wml page.if a user visit the site from opera using mobile it will also redirect to the wml page.and if a user visit the site using firefox also have addon for wml support will also go to the wml page otherwise if don't have then pc.and all the browser using pc do not support wml will be directed to the pc web page.and if the browser support wml it will redirect to wml page.

let me search for you because u cant !!

click on this link

http://coding-talk.com/f16/new-redirection-script-3855/

bijaybd Developer · 178 posts #3

it won't work perfect as i want it . i didn't where to put the url for pc users.

bijaybd Developer · 178 posts #5
<?php

global $userBrowser;

// Your wapsite

$wmllink = "wap/index.php";

// Your website

$htmllink = "web/index.php";

//Detect the browser
$userBrowser = $_SERVER['HTTP_USER_AGENT']; 

//echo $userBrowser;

if(strpos(strtoupper($HTTP_ACCEPT),"VND.WAP.XHTML+XML") > 0)
{
  $ub="PC";
}
else if(strpos(strtoupper($HTTP_ACCEPT),"XHTML+XML") > 0)
{
  $ub="PC";
}
//Check for Mozilla
else if(stristr($userBrowser, 'Mozilla')) 
{
  $ub="PC";
}
//Check for msie
else if(stristr($userBrowser, 'msie')) 
{
  $ub="PC";
}
//Check for IE
else if(stristr($userBrowser, 'internet explorer')) 
{
  $ub="PC";
}
//Check for opera
else if(stristr($userBrowser, 'opera')) 
{
  $ub="pc";
}
//Check for Opera
else if(stristr($userBrowser, 'Opera')) 
{
  $ub="pc";
}
else
{
  $ub="WML";
  }
if($ub == "PC") {
    header("Location: ".$htmllink);
    exit;
    }
    else 
    {
    header("Location: ".$wmllink);
    exit;
    }    
?>

i have also tried this won't work

kazzin Junior · 33 posts #6

this will work 😀

//Define your mobile website alternative
$site = "http://ursitename.com/xhtml";

//Defines the user browser
$agent = $_SERVER['HTTP_USER_AGENT'];

//Check for various mobile browsers and redirect if confirmed
if (eregi("mozilla", $agent)) {
header( "Location: $site" ) ;
}
if (eregi("internet explorer", $agent)) {
header( "Location: $site" ) ;
}
if (eregi("Blazer", $agent)) {
header( "Location: $site" ) ;
}
if (eregi("Plucker", $agent)) {
header( "Location: $site" ) ;
}
if (eregi("AvantGo", $agent)) {
header( "Location: $site" ) ;
}
kiLLeR-eyEd_14 Senior · 382 posts #7

bijaybd wrote:

<?php

global $userBrowser;

// Your wapsite

$wmllink = "wap/index.php";

// Your website

$htmllink = "web/index.php";


//Detect the browser
$userBrowser = $_SERVER['HTTP_USER_AGENT']; 


//echo $userBrowser;

if(strpos(strtoupper($HTTP_ACCEPT),"VND.WAP.XHTML+XML") > 0)
{
  $ub="PC";
}
else if(strpos(strtoupper($HTTP_ACCEPT),"XHTML+XML") > 0)
{
  $ub="PC";
}
//Check for Mozilla
else if(stristr($userBrowser, 'Mozilla')) 
{
  $ub="PC";
}
//Check for msie
else if(stristr($userBrowser, 'msie')) 
{
  $ub="PC";
}
//Check for IE
else if(stristr($userBrowser, 'internet explorer')) 
{
  $ub="PC";
}
//Check for opera
else if(stristr($userBrowser, 'opera')) 
{
  $ub="pc";
}
//Check for Opera
else if(stristr($userBrowser, 'Opera')) 
{
  $ub="pc";
}
else
{
  $ub="WML";
  }
if($ub == "PC") {
    header("Location: ".$htmllink);
    exit;
    }
    else 
    {
    header("Location: ".$wmllink);
    exit;
    }    
?>

i have also tried this won't work

this is what i'm using and it's working fine

bijaybd Developer · 178 posts #8

yep but not with mobile and pc .. i just want like if browser accpet wml den it will redirect to wml site whatever it is from pc or mobile and if the browser do not support wml it will redirect to pc site

Write your reply now; next you create a free account (or sign in) and it is posted right away. Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close