User agent detection for mobile: I'm new to this

I’ve just read the article on designing for mobile devices (http://articles.sitepoint.com/article/designing-for-mobile-web/) and I’m curious about other opinions on this process.

Ideally I’d like to do something like digg.com and m.digg.com. If I understand correctly, digg uses some user agent detection to forward it to their mobile version of the site. Is that what they’re doing? Or is it more complicated than that? That’s more or less what I want to achieve. I want my sites to redirect to the official mobile version but offer the viewers the option to see the regular instead.

Can anyone offer clarification on how this is performed or if I understand the concepts clearly enough? The article sort of recommends against user agent detection which I find confusing.

Thanks in advance.

My current feeling is that it’s better—in general—to work with one site that all devices can use in some way, but that may not suit all sites.

Have a look at this challenging slideshow before you decide how to go about designing for mobile. It’s a bit controversial, and maybe a bit experimental, but it’s great food for thought:

Rethinking the Mobile Web