Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redirect mobile devices to alternate version of my site

Tags:

We've got an alternate version of out website ready for mobile devices. The content we serve is different and it works well.

What is the best way to detect which version to serve. We don't have a list of all mobile devices so to use the user-agent header is tricky as we may miss something.

We thought about useing device screen width - but what happens if the mobile device doesnt support javascript. How do we sniff this ?

like image 716
32423hjh32423 Avatar asked Jul 13 '09 09:07

32423hjh32423


People also ask

How do I redirect a website to a mobile version when accessed on a mobile device?

Add a rel="alternate" tag on the desktop page which points to the corresponding mobile URL. Add a rel="canonical" tag on the mobile page that points to the corresponding desktop URL. This allows Google's crawlers to understand the relationship between the two URLs – desktop and mobile.

What is mobile redirection?

When the user accesses a site using a mobile device, the user redirects to another site if this parameter is turned on. If the site uses a responsive or foundation template, you must turn off the Mobile Redirection setting.


1 Answers

You could use a device description database (such as WURFL) which will recognise the client device from the request headers. You can then query that database to decide if the device can handle your site (e.g. support javascript, or is the screen big enough) before deciding whether to redirect them to a different site.

You don't mention your environment, but WURFL supplies APIs for Java and PHP, and maybe others as well. If there's no supplied API, you can still use WURFL, but you'll have to parse and process the XML data yourself.

like image 128
skaffman Avatar answered Oct 17 '22 03:10

skaffman