I have some special coding that only works for HTML5 browsers (simple geolocation stuff). I want to redirect iPhone and Android users to the m.example.com version of my website. How is the best way to do this?
you can use UserAgent detection, or you can use the jQuery.support(). Since you are looking for specific functionality, you can combine the two to get what you want.
You can see the (mostly) exhaustive list of mobile user agents on the wikipedia page. As you can see there are similarities between manufacturers and versions that you could look for in a regular expression.
Your question touch two parts .. redirection and html5 compatibility.
I'm using the following .htaccess :
For php you can use this library: http://detectmobilebrowsers.mobi/ ... but i strongly suggest using htaccess for processing time and security.
You can find some additional examples here
The excellent HTML5 boilerplate template is using modernizr out of the box to support this kind of needs.
My opinion is : I suggest to use the htaccess method for everything except recent phones and browsers supported by modernizr and let Android and iPhone users be checked by Modernizr for html5 feature support and redirect the "rest" on your "without geolocation" version.
Modernizr example :
Hope this helps