Skip to content

Instantly share code, notes, and snippets.

@fnhipster
Created April 25, 2013 15:27

Revisions

  1. fnhipster created this gist Apr 25, 2013.
    11 changes: 11 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    # MOBILE REDIRECT
    RewriteCond %{REQUEST_URI} !/mobile.*$
    RewriteCond %{REQUEST_URI} !/hub.*$

    RewriteCond %{HTTP_USER_AGENT} "android|blackberry|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]
    RewriteRule ^(.*)$ /mobile [L,R=302]

    # if a user is accessing a mobile page from desktop then show desktop version
    RewriteCond %{HTTP_USER_AGENT} "!android|!blackberry|!iphone|!ipod|!iemobile|!opera mobile|!palmos|!webos|!googlebot-mobile" [NC]
    RewriteRule ^mobile/(.*)$ / [L,R=302]
    # END MOBILE