0

I have viewed a few questions here

Mobile Redirect using htaccess

Redirection for Mobile using .htaccess - only on homepage

I know its been answered before but I tried to implement what I found with no luck.

I would like to know how to redirect mobile users only for the homepage of my wordpress site through .htaccess

I need users from mobile to be redirected ONLY for the home page www.mysite.com to www.mysite.com/mobilehome. All other pages have to stay the same for mobile and desktop.

Any help appreciated.

Thanks

Community
  • 1
  • 1
bax
  • 119
  • 10
  • Why don't use `wp_is_mobile()` and `wp_redirect()` instead? – wpclevel Apr 20 '16 at 19:19
  • Because of the caching system which interferes with that process. Using it directly from htaccess would make me able to leave my caching configuration as is which is optimal. – bax Apr 20 '16 at 19:36

1 Answers1

1

After alot of searching and tests I found the solution:

# BEGIN Mobile redirect
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]
RewriteCond %{HTTP_HOST} domain\.com [NC]
RewriteCond %{REQUEST_URI} ^/$
Rewriterule ^(.*)$ http://www.domain.com/mobile-url [L,R=301]
</IfModule>
# END Mobile redirect
bax
  • 119
  • 10