To redirect only mobile traffic to a mobile domain there are a few options:-
Simple
Based on screen resolution (my favorite as it's fairly future proof)
<script type="text/javascript">
<!--
if (screen.width <= 699) {
document.location = "www.mobileurl.com";
}
//-->
</script>
More granular control
http://detectmobilebrowsers.mobi/ offers more complete control with a free script which handles redirection to a single place, or multiple places based on device (don't be fooled by all the buy buttons!)
require_once('[mobile_device_detect.php][4]');
mobile_device_detect(
'http://iphone-url.com',
'http://ipad-url.com',
'http://android-url.com',
'http://opera-mini-url.com',
'http://blackberry-url.com',
'http://palm-os-url.com',
'http://mobile-url.com',
'http://mobile-browsers-url.com',
'http://desktop-url.com');
Allowing traffic from different devices to be sent to different urls.
Extremely granular control
Other than that there are device description databases like WURFL which offer even more in depth control by providing a database that can be queried using device header information and traffic redirected accordingly...