Register Advertise with usHelp Desk Today's Posts Search

Closed Thread
Thread Tools Search this Thread
Unread 8th Mar 2012, 05:33 AM   #1
HyperActive Warrior
 
Join Date: 2010
Location: UK
Posts: 339
Thanks: 92
Thanked 72 Times in 55 Posts
Default
Mobile Redirect Code???
Share on: 
fb share twitter share gplus share more share

I have built a mobile website and am now ready to set up the redirect from the main site.

How do i do this? and where do i get the redirect code from?

I have read that the best method is by user agent/php and not java script.
Can anyone point me in the right direction with a code and a tutorial on how to do this.

The site is not on wordpress otherwise i would of just used a plugin like i have before.

Many thanks
zimbizee is offline  
Unread 8th Mar 2012, 10:47 AM   #2
Ultimate Warrior
 
HypeText's Avatar
 
Join Date: 2011
Posts: 734
Thanks: 28
Thanked 181 Times in 131 Posts
Default
Re: Mobile Redirect Code???
Share on: 
fb share twitter share gplus share more share

Originally Posted by zimbizee View Post

I have built a mobile website and am now ready to set up the redirect from the main site.

How do i do this? and where do i get the redirect code from?

I have read that the best method is by user agent/php and not java script.
Can anyone point me in the right direction with a code and a tutorial on how to do this.

The site is not on wordpress otherwise i would of just used a plugin like i have before.

Many thanks
There are different types of Redirect Codes...

Use JavaScript

This is what most people want to do. They want to use some type of browser detection script to detect if the customer is on a mobile device and then redirect them to the mobile site. The problem with browser detection and mobile devices is that there are thousands of mobile devices out there. To attempt to detect them all with one JavaScript script could turn all your pages into a downloading nightmare.

Then there is the fact that many mobile devices don't (currently) support JavaScript. So, using a browser detection script will be voided from the get-go as their browsers don't run the script in the first place. I read in one forum that the solution is to assume that anyone browsing with no JavaScript is probably a cell phone or mobile device, and so should be shown the cell phone or mobile site. I hope I don't have to explain to you the problem with this solution. If you don't know, here's a hint - the iPhone supports JavaScript, as do other mobile devices.

Use CSS @media handheld


The CSS command @media handheld is a way to display CSS styles just for handheld devices - like PDAs, cell phones, and so on. This seems like an ideal solution for displaying pages for mobile devices. You write one Web page, and then create 2 style sheets. The first for the "screen" media type styles your page for monitors and computer screens. The second for the "handheld" styles your page for small devices like PDAs and cell phones.
The biggest advantage to this method is that you don't have to maintain two versions of your website. You just maintain the one, and the style sheet defines how it should look.
The problem is that many cell phones don't support the handheld media type - they display their pages with the screen media type by mistake. Lots of other cell phones and handhelds don't support CSS at all.

Use PHP, JSP, ASP, etc. to Detect the User-Agent


This is a much better way to redirect mobile users to a mobile version of the site, because it doesn't rely on a scripting language or CSS that the mobile device doesn't use. Instead, it uses a server-side language (PHP, ASP, JSP, ColdFusion, etc.) to look at the user-agent and then change the HTTP request to point to a mobile page if it's a mobile device.
A simple PHP code to do this would look like this:

<? if ( stristr($ua, "Windows CE") or stristr($ua, "AvantGo") or stristr($ua,"Mazingo") or stristr($ua, "Mobile") or stristr($ua, "T68") or stristr($ua,"Syncalot") or stristr($ua, "Blazer") ) { $DEVICE_TYPE="MOBILE"; } if (isset($DEVICE_TYPE) and $DEVICE_TYPE=="MOBILE") { $location='mobile/index.php'; header ('Location: '.$location); exit; } ?>

The problem here is that there are lots and lots of other potential user-agents that are used by mobile devices. This script will catch and redirect a lot of them, but not all by any means. And more are added all the time.

Plus, as with the other solutions above, you'll have to maintain a separate mobile site for these readers.

Use WURFL

If you are still determined to redirect your mobile users to a separate site, then WURFL (Wireless Universal Resource File) is a good solution. This is an XML file (and now a DB file) and various DBI libraries that not only contain up-to-date wireless user-agent data, but also what features and capabilities those user-agents support.

To use WURFL, you download the XML configuration file, and then pick your language and implement the API. There are tools for using WURFL with Java, PHP, Perl, Ruby, Python, .Net, XSLT, and C++.

The benefit of using WURFL is that there are lots of people updating and adding to the config file all the time. So while the file you're using is out-of-date almost before you've finished downloading it, chances are that if you download it once a month or so, you'll have all the mobile browsers your readers habitually use without any problems.
Also, it does more than just detect the user-agent, it tells you which devices support what. So if you want to (for example) set up a WAP push, you could provide that service only to the devices that support it. Other devices would not even see the link.


Borrowed from about.com

(916) 520-HYPE (4973)
Local & Mobile Marketing Solutions
$0 Setup & $99/mnth Private Label Reseller Accts
HypeText is offline  
The Following 2 Users Say Thank You to HypeText For This Useful Post:
Unread 8th Mar 2012, 09:02 PM   #3
Mobile+WP = JumpMobi.com
War Room Member
 
Jay Moreno's Avatar
 
Join Date: 2009
Location: San Antonio, Tx
Posts: 1,270
Thanks: 301
Thanked 449 Times in 309 Posts
Default
Re: Mobile Redirect Code???
Share on: 
fb share twitter share gplus share more share

how is your main site coded? ie php, asp, basic html

knowing that will help determine the best solution for you

one other method not mentioned above is also using a .htaccess file for redirection

Sorry, I am too busy helping people to think of a cool signature!
Jay Moreno is offline  
Unread 9th Mar 2012, 03:03 AM   #4
HyperActive Warrior
 
Join Date: 2010
Location: UK
Posts: 339
Thanks: 92
Thanked 72 Times in 55 Posts
Default
Re: Mobile Redirect Code???
Share on: 
fb share twitter share gplus share more share

Hi thanks for the replies.

The main site is coded in html i believe at Mr Site
who are a one of these 1 stop website builder/hosting companies.

The guy i am going to be building the mobile site for built the main site here using their software. I will try and convince him to let me build a new site from scratch, but that's another story.

What do you think would be the best solution in this case?

Cheers
zimbizee is offline  
Closed Thread


Bookmarks

Tags
code, mobile, redirect


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -6. The time now is 10:08 PM.