You CAN check for the existence of a resource identified by an HTTP URL using mod_rewrite
See example below:
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]
RewriteCond %{REQUEST_URI} ![.]html$
RewriteCond %{REQUEST_URI} ^([^.]*)
RewriteCond %1.html -U
RewriteRule ^.*$ $0.html [R=302, L]
The import part is line 4 and the -U flag that checks if a resource exists. Note, that using this flag does impact performance on the web tier.
Other things to note. Firstly I have used a hack regex for user agent string to dtermine if the user agent is on a mobile device. This isn't always the best approach, depending on how extensible you want to make it. You might want to consider using the Apache Mobile Filter and the using a rewrite cond as follows (in place of the user agent cond):
RewriteCond %{ENV:AMF_DEVICE_IS_MOBILE} ^true
Finally, as DisgruntledGoat mentions, it is usually better to first use responsive web design and then only consider server side negotiation if you have a considerably different information architecture.
header('Location: http://newpage/')– ionFish May 30 '12 at 16:22