RewriteEngine on
# Check if this is the desktop to mobile query string
RewriteCond %{QUERY_STRING} (^|&)m=1(&|$)
# Set a cookie, and skip the next 2 rules
RewriteRule ^ - [CO=mredir:1:%{HTTP_HOST},S=2]
# Check if this is the mobile to desktop query string
RewriteCond %{QUERY_STRING} (^|&)m=0(&|$)
# Set a cookie, and skip the next rule
RewriteRule ^ - [CO=mredir:0:%{HTTP_HOST},S]
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]
# Check if we're not already on the mobile site
RewriteCond %{HTTP_HOST} !^m\.
# Can not read and write cookie in same request, must duplicate condition
RewriteCond %{QUERY_STRING} !(^|&)m=0(&|$)
# Check to make sure we haven't set the cookie before
RewriteCond %{HTTP_COOKIE} !^.*mredir=0.*$ [NC]
RewriteRule ^(.*)$ http://m.website.com/ [L,R=302]
# 1.) Check if on desktop site and having www., if not redirect to www.website.com
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} !^m\. [NC]
RewriteRule ^(.*)$ http://www.website.com$1 [R=301,L]
2.) Это не может быть сделано с помощью mod_rewrite, за исключением того, что "/ стулья" - это существующий файл (и я предполагаю, что это не так). Так что я бы проверил это на желаемом языке сценариев - например, в php:
if (!pageexists($_GET['page']) && $_SERVER['HTTP_HOST'] == 'm.website.com')
header("Location: http://m.website.com/");
где pageexists () - это функция, которую вы определяете для проверки наличия контента для этой страницы в мобильной версии.