Options +FollowSymlinks RewriteEngine on # Redirection msie (MS IE < 11 - otherwize "desktop" is used) Rewritecond %{http_host} ^example.com [nc] RewriteCond %{HTTP_USER_AGENT} "MSIE" RewriteCond %{REQUEST_URI} !\/my-path-from-web-root\/android RewriteCond %{REQUEST_URI} !\/my-path-from-web-root\/iphone RewriteCond %{REQUEST_URI} !\/my-path-from-web-root\/wp RewriteCond %{REQUEST_URI} !\/my-path-from-web-root\/msie RewriteCond %{REQUEST_URI} !\/my-path-from-web-root\/desktop RewriteRule ^(.*)$ /my-path-from-web-root/msie/$1 [NC,L] # Redirection Windows Phone devices Rewritecond %{http_host} ^example.com [nc] RewriteCond %{HTTP_USER_AGENT} "Windows Phone" RewriteCond %{REQUEST_URI} !\/my-path-from-web-root\/android RewriteCond %{REQUEST_URI} !\/my-path-from-web-root\/iphone RewriteCond %{REQUEST_URI} !\/my-path-from-web-root\/wp RewriteCond %{REQUEST_URI} !\/my-path-from-web-root\/msie RewriteCond %{REQUEST_URI} !\/my-path-from-web-root\/desktop RewriteRule ^(.*)$ /my-path-from-web-root/wp/$1 [NC,L] # Redirection iPhone or iPad devices Rewritecond %{http_host} ^example.com [nc] RewriteCond %{HTTP_USER_AGENT} iPhone|iPad RewriteCond %{REQUEST_URI} !\/my-path-from-web-root\/iphone RewriteCond %{REQUEST_URI} !\/my-path-from-web-root\/android RewriteCond %{REQUEST_URI} !\/my-path-from-web-root\/wp RewriteCond %{REQUEST_URI} !\/my-path-from-web-root\/msie RewriteCond %{REQUEST_URI} !\/my-path-from-web-root\/desktop RewriteRule ^(.*)$ /my-path-from-web-root/iphone/$1 [NC] # Redirection Android devices Rewritecond %{http_host} ^example.com [nc] RewriteCond %{HTTP_USER_AGENT} Android RewriteCond %{REQUEST_URI} !\/my-path-from-web-root\/android RewriteCond %{REQUEST_URI} !\/my-path-from-web-root\/iphone RewriteCond %{REQUEST_URI} !\/my-path-from-web-root\/wp RewriteCond %{REQUEST_URI} !\/my-path-from-web-root\/msie RewriteCond %{REQUEST_URI} !\/my-path-from-web-root\/desktop RewriteRule ^(.*)$ /my-path-from-web-root/android/$1 [NC] # Redirection for everything not identfied as before (fallback is "desktop") Rewritecond %{http_host} ^example.com [nc] RewriteCond %{HTTP_USER_AGENT} ^(?:(?!iPhone|iPad|Android|Phone).)*$ RewriteCond %{REQUEST_URI} !\/my-path-from-web-root\/android RewriteCond %{REQUEST_URI} !\/my-path-from-web-root\/iphone RewriteCond %{REQUEST_URI} !\/my-path-from-web-root\/wp RewriteCond %{REQUEST_URI} !\/my-path-from-web-root\/msie RewriteCond %{REQUEST_URI} !\/my-path-from-web-root\/desktop RewriteRule ^(.*)$ /my-path-from-web-root/desktop/$1 [NC]