[HELP]Mobile Redirect on homepage ONLY to a mobile Homepage (4 posts)

  1. docwho
    Posted 3 years ago #

    I have a site where cannot live without this flash slider plugin that is only found on the homepage. I figured that I would just create another page that looks the same as the homepage, but replace the flash slider with a JS slider. Then I would just redirect mobile users from the homepage to the mobile homepage.

    I want mobile users who goes to http://example.com to go to http://example.com/mobilehome instead. However if a mobile user goes to http://example.com/about I don't want them going to http://example.com/mobilehome. I only need a mobile redirect on the homepage only.

    To my surprise I couln't find a plugin that only allowed a mobile redirect from one page to another. I know the cheesy workaround would be have two different WP installs that emmulate eachother and just use a plugin that redirects users to that other site, but that means I have to copy every post I do.

    I have attempted a couple of ways of doing this.

    FAIL attempt at doing this with PHP

    if(is_home()) {

    I am using this script, mobile_device_detect.php from http://detectmobilebrowsers.mobi/

    FAIL attempt at doing it in httaccess

    # BEGIN Mobile redirect for the video
    <IfModule mod_rewrite.c>
        RewriteEngine On
        # RewriteRule ^mobile/ - [L]
        # redirect /example.com/index.html to /mobilehome/index.html for mobile browsers
        RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]
        RewriteRule ^\index.php$ /mobilehome/index.php [L,R=302]
    # END Mobile redirect

    If anyone knows a good way of doing this mobile direction, please help!!!

    Thanks in advance!

  2. chuckpix
    Posted 3 years ago #

    i am also desperate for a solution to this!

  3. Mat Lipe
    Posted 3 years ago #

    I was able to get this to work using the http://detectmobilebrowsers.mobi/ 's code and a little variation of what you tried before.
    I uploaded the php file from the detectmobilebrowers.mobi site to my child theme's folder and added the following code to the functions.php file in my child theme.


    Worked like a charm.

    Hope this helps.


  4. ktrusak
    Posted 3 years ago #

    Pardon the bump on an old post.

    Mat Lipe-- I tried using your solution, but it seems to redirect all my pages from mobile devices to the selected page. Do you know how to set only one redirect (for the homepage)?

Topic Closed

This topic has been closed to new replies.

About this Topic