In Focus
Kolkata Chapter Developer Day: May 25
C# Corner Delhi Chapter Meet, May-18, 2013 Official Recap
Istanbul Chapter May 2013 2nd Seminar Announced : Learn WinJS, Windows Store, MVC
ANNOUNCEMENT: April 2013 Month Winners
Email :
Password :
Remember me?
Forgot password
Contribute
An Article
A Blog
A News
A Video
A Link
An Interview Question
Ask a Question
TECHNOLOGIES
.NET 4.5
Current Affairs
Learn .NET
SharePoint 2010
Web Development
.NET Assemblies
Databases & DBA
LightSwitch 2012
SharePoint 2013
Web Services in C#
ADO.NET in C#
Design & Architecture
LINQ
Silverlight with C#
Windows 8
AJAX in C#
Exception Handling C#
Mobile & Embedded
Smart Devices
Windows Azure
Android Programming
Graphics Design
Office 2013
SQL
Windows Controls C#
Articles C#
Hardware
OOP/OOD
SQL Server 2012
Windows Forms C#
ASP.NET Controls in C#
How do I
Operating Systems
Testing
Windows Phone 8
ASP.NET MVC with C#
HTML 5
PHP
TypeScript
Windows Server 2012
ASP.NET Programming
Internet & Web
Products
Visual C#
Windows Store Apps
C# Language
iPhone/iPad
Project Management
Visual Studio .NET
Workflow Foundation in C#
C# Tutorials
Java
Reports using C#
Visual Studio 2010
WPF
C, C++, MFC
Java and .NET
Robotics & Hardware
Visual Studio 2012
XAML
Career Advice
JavaScript, CSS
Security in .NET
WCF with C#
XML
Chapters
JQuery
Request a new Category
|
View All
ANSWERS
BLOGS
VIDEOS
INTERVIEWS
BOOKS
LINKS
NEWS
CHAPTERS
CAREER ADVICE
Making your Web Browser in C#
HTML 5 vs Native Apps
Secure Your Android Application from Hackers
Why to fear Object Oriented Programming approach
Check upcoming B'day in Asp.net
Happy Birthday Destin Joy
Compare strings using StringComparison.Ordin ...
Class vs Structure
Get The Value From DataGridView To TextBox On c#
Access Master Page Control In Child Page
Blog
Redirect your website mobile users to your mobile site in PHP
Posted by
RAJESH YADAV
in
Blogs
|
PHP
on
Apr 19, 2012
Are you looking for mobile website redirection script. Take a look at this post I want to explain how to detect mobile user agents like Android, Iphone and Blackberry.
Tweet
1923
0
0
Are you looking for mobile website redirection script. Take a look at this post I want to explain how to detect mobile user agents like Android, Iphone and Blackberry. Many people are suggested to redirect with .htaccess file but I had implemented this with PHP. It is very easy just few lines of code.
PHP Code:
<?php
echo $_SERVER['HTTP_USER_AGENT'];
?>
now what you have to do is make a new php file named user_agent.php
<?php
$iphone = strpos($_SERVER['HTTP_USER_AGENT'],"iPhone");
$android = strpos($_SERVER['HTTP_USER_AGENT'],"Android");
$palmpre = strpos($_SERVER['HTTP_USER_AGENT'],"webOS");
$berry = strpos($_SERVER['HTTP_USER_AGENT'],"BlackBerry");
$ipod = strpos($_SERVER['HTTP_USER_AGENT'],"iPod");
if ($iphone || $android || $palmpre || $ipod || $berry == true)
{
header('Location: http://yourmobilesitelink.com/');
//OR
echo "<script>window.location='http://yourmobilesitelink.com'</script>";
}
?>
Index.php or Home.php
You have to include like following script.
PHP Code:
<?php
include('user_agent.php'); // Redirecting http://mobile.site.info
// site.com data
?>
for symbian os add this line in your existing code :
$SymbianOS = strpos($_SERVER['HTTP_USER_AGENT'],"SymbianOS");
and add this function to if statement as below :
if ($SymbianOS || $iphone || $android || $palmpre || $ipod || $berry == true)
This Feature is Sponsored By
DynamicPDF Merger is a developers dream for interacting with any existing PDF documents. Merge, append, split, form fill, flatten stamp and so much more.
Load Time Script - PHP
Insert Value from Checkbox in MySql Database in PHP
post comment
COMMENT USING
PREMIUM SPONSORS
iPhone, Android & Web Development Services
Over-C is a holistic consortium of communications and technology specialists. We build, deploy and market both business as well as consumer products and solutions.
More Blogs from this Blogger
Redirect your website mobile users to your mobile site in PHP
View All
SPONSORED BY
DynamicPDF ReportWriter Suite
PDF reports have never been easier to create. With our included WYSIWYG Designer, you can layout your reports, set up your data source and let DynamicPDF ReportWriter do the rest.
Follow @twitterapi
Latest Blogs
How to get thumbnail image from youtube embed code
Spilit Letter Of Word From String in SQL Server
Install Ajax control Toolkit in Visual Studio 2008
How to highlight grid view row and change row color on mouse over and Check box selection in ASP.NET
Import Email from Gmail in ASP.NET
LEN and DATALENGTH Function in SQL Server
TextBox validation using JQuery
Android Studio not Starting Up After Installation
Check upcoming B'day in Asp.net
Get The Value From DataGridView To TextBox On c#
View All
Poll
Result
All Polls
What is the best product to build Mobile apps?
What is the best product to build Mobile apps
PhoneGap
Icenium
Xamarin Studio
KendoUI Mobile
JQueryMobile
Native iOS/Android
What is the best product to build Mobile apps
Options
Votes
%
PhoneGap
0
0.00
Icenium
0
0.00
Xamarin Studio
0
0.00
KendoUI Mobile
0
0.00
JQueryMobile
60
90.91
Native iOS/Android
6
9.09
Total
66
100%