Your question seems to be a possible duplicate of this one:
Auto detect mobile browser (via user-agent?)
That being said, the accepted answer there suggested:
Reading the User-Agent header will do the trick.
There are some lists out there of known mobile user agents so you
don't need to start from scratch. What I did when I had to is to build
a database of known user agents and store unknowns as they are
detected for revision and then manually figure out what they are. This
last thing might be overkill in some cases.
If you want to do it at Apache level, you can create a script which
periodically generates a set of rewrite rules checking the user agent
(or just once and forget about new user agents, or once a month,
whatever suits your case), like
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} (OneMobileUserAgent|AnotherMobileUserAgent|...)
RewriteRule (.*) mobile/$1
which would move, for example, requests to http://domain/index.html to http://domain/mobile/index.html
Additionally, the link in the linked-StackOverflow-accepted answer is broken. However, you can follow this one (which is up to date):
http://www.enterpriseios.com/wiki/UserAgent
Additional References: What is the iPhone 4 user-agent?