I learned these rules from various sources. Do any of you see any pitfalls?
I use this to customize the mobile version of the ZendFramework-based website.
RewriteEngine On
RewriteCond %{ENV:REDIRECT_STATUS} =""
RewriteCond %{HTTP_REFERER} !domain\.com
RewriteCond %{REQUEST_URI} !^/m
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-s
RewriteCond %{REQUEST_URI} !^/favicon.ico
RewriteCond %{HTTP_USER_AGENT} .*Mobile.*Safari
RewriteRule ^(.*)$ /m/$1 [R,L]
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-s
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/favicon.ico
RewriteRule ^.*$ index.php [NC,L]
I'm not a mod_rewrite expert, so what do [R, L] and [NC, L] mean?
Update
Just test it with your iPad and it does not redirect it. But then again, I think the mobile version will not be needed for the iPad. What do you think?
Update upon update
Hmm .. just realized that switching directly to http://www.domain.com/from the iPhone does not work, but it is. Adding something to a request, for example http://www.domain.com/tracker, is redirected correctly to http://www.domain.com/m/tracker. Perhaps that is why the iPad did not show the mobile site (and I do not have an iPad in my hands right now).
Third update
, http://www.domain.com/. RewriteCond %{REQUEST_FILENAME} !-d.