Skip to content

Instantly share code, notes, and snippets.

@fnhipster
Created April 25, 2013 15:27
Show Gist options
  • Save fnhipster/5460604 to your computer and use it in GitHub Desktop.
Save fnhipster/5460604 to your computer and use it in GitHub Desktop.
Mobile/Desktop htaccess redirect
# 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment