Code 96 WordPress Design has listened to the readers of the popular PHP Mobile Redirect post, and has just released a plugin to assist WordPress users.  The PHP Mobile Redirect Plugin will easily integrate the popular mobile redirect solution that many of you have used on your sites.  You now have the option to easily integrate the PHP Mobile Redirect Plugin on your WordPress site.

PHP Mobile Redirect Plugin

PHP Mobile Redirect Plugin Download

The plugin is hosted in the WordPress plugin database, and has received several downloads on the first day of this launch.  This plugin is free for use, and has been designed as light weight as possible.  Visit the following link to download this plugin and start redirecting your mobile users.

Plugin Installation

1.  Upload the zip file to the /wp-content/plugins/ directory.

2.  Activate the plugin through the ‘Plugins’ menu in WordPress.

3.  Go to Settings > PHP Redirect.

4.  Put in the mobile site URL (excluding http://) to the website you would like to redirect mobile traffic to.

6.  Select the name of the cookie you will set on your mobile site to bypass the redirect.

7.  Select “Save Options” and you are done.

Plugin Settings

The PHP Mobile Redirect Plugin settings are found in your WordPress dashboard under Settings > PHP Redirect.  You will need to visit the plugin options page to enter your mobile site URL (excluding http://), and set the name of the cookie on your mobile site.  The cookie name is important, as it is set once a visitor visits your mobile site.  You may then provide a “View Full Site” link on your mobile site, and users returning to your full site will bypass the redirect.

Support

Code 96 WordPress Design is committed to the PHP Mobile Redirect Plugin, and hope to help you handle your mobile traffic.  If you find an error or have any suggestions, we would love to hear from you.  Please drop us a line and we will get back to you as soon as possible.

Reader Interactions

Comments

  1. Can I set this up so that I can redirect at the page level? In other words I want each desktop page to redirect to a unique mobile page when accessed by a mobile device.

    • Dave,

      That functionality is not included in the current plugin, but we will keep it in mind for future versions. How many pages are you trying to redirect?

      • I could really use this as well. We have a responsive theme but would like it to switch to a different page without a slider for mobile devices to make it lighter. I’ve searched long and hard for something like this but can’t find anything — they all switch themes, not pages.

        Ray

  2. Thanks for your plugin. I’ve got everything working except the link back to the full site. When I add

    to my index.php page I start getting a warning error that says the header cannot be modified and it redirects me right back to the mobile side. Is this an issue with another plugin or the way wordpress works? The only other thing I can think of is that it’s because I have the mobile site in it’s own directory…
    mydomain.com/mobile/
    Any help with this would be greatly appreciated

        • I’m having the same problem with the “headers already sent” error – the mobile website is a basic PHP page in a subdomain, completely separate to the WordPress install. Any help would be appreciated!

          • I did manage to fix it – I was putting the “setcookie” code after the header, which I have now found out it needs to be placed before any HTML on the page, and then it works 🙂

            If possible, it would be great if you could add into the plugin where the code should go, because I’m sure I’m not the only one it’s happened to 🙂

  3. I love this plug in, I want to say first off. Secondly, I cannot figure out for the life of me to get the back to full site link to work. I have added the php provided into the functions.php to add the cookie of my mobile wordpress site and when I link back to the main domain from my mobile subdomain it still redirects me to the mobile site. I’ve also tried putting it in header.php, nothing seems to work.

    • The updated plugin has implemented a feature to enable or disable the plugin. You need to go to Settings > PHP Mobile Redirect and select the “enable” checkbox.

  4. Hi, it doesn’t work in the iPad, any ideas why? It redirects me from the iPhone just fine but not the iPad, please help..

      • Hi… I’m using version 1.2 and the ipad gets redirected but shouldn’t. Newest ipad (4th gen) being used. Is that what is supposed to happen? Could that be an option? The ‘view full site’ link works perfectly.

        • The iPAD is supposed to be redirected using this plugin. I am planning on adding an option to disable it in the next release (which I expect to kick out soon). In the meantime, you could modify the plugin functions.php pmr_mobile_reidrect() function to add the following under the if statement:

          			 
          			elseif ($detect->isiPad())
          			{
          				$detect = "false";
          			}
          
          
    • Allison,

      The PHP code must come before any HTML. You should place the PHP to set the cookie at the very top of your mobile index page before any HTML, and your mobile index page must contain a .php extension.

      Let me know if this fixes the problem.

      • Hi again. Thanks for the quick reply! It is truly appreciated!

        I have the the plugin enabled on the non-mobile domain: http://www.lunabeanmedia.com.

        The mobile site is on another domain: http://www.tasterstuart.com.

        The redirect is working fine.

        On the mobile site (tasterstuart.com), I have the cookie code outputted within the tags. You can view source on that domain to see it.

        When I click on my link to “view full site” it attempts to go back to the non-mobile site (lunabeanmedia.com) and then redirects back to the mobile version.

        Both sites are wordpress sites.

        Any help is greatly appreciated. Thanks so much.

        • Sorry for the edit here, but the comment system stripped my *head* tag code.

          The sixth paragraph should read:

          On the mobile site (tasterstuart.com), I have the cookie code outputted within the HEAD /HEAD tags (not within the BODY /BODY tags). You can view source on that domain to see it.

          • Allison,

            The PHP must come before any HTML. Since your mobile site is WordPress, you will need to add something like the following to your themes functions.php file:

            add_action('init', 'themename_set_cookie');
            
            function themename_set_cookie() {
            
                      setcookie("mobile","m", time()+3600, "/",".lunabeanmedia.com"); 
            
            }
            
          • Wish I could report better news, but this didn’t work. 🙁

            Any other ideas?

  5. Hi
    Your plugin is great, but I am having the same trouble with the redirect to the mobile site not allowing mobile users to go to the main site home page.
    I think many others like myself will have a wordpress site, and use another wordpress mobile site in a subfolder like m.domain.com.

    This being the case, can you tell us what code we use to enter the cookie that allows mobile users to go to the main site home page, and especially exactly where do we put it in the mobile wordpress site files?

    Thanks a million

      • We were able to help Kat using the following solution, which we plan on adding to the tutorial and plugin instructions:

        1. Create a directory in the root of your main or mobile site name go or full-site etc.
        2. Create a new document called go.php or full-site.php.
        3. Include the following code in the PHP document:

        <?php 
        setcookie("mobile","m", time()+3600, "/");
        
        header("Location: your sites url");
        ?>
        

        replace your sites url with the link to your main site’s home page.

        4. Change the reference to of your “View Full Site” link to http://www.yourhomesite/go/go.php

        * The above url represents the path if you named your directory go and the file go.php. Change filenames and path as necessary.

        • I have followed the same but it’s going to full site and immediately redirecting to mobile site. my both sites are wordpress only

  6. Your plugin is working fine for redirecting from desktop url to mobile. But for view full site link it’s going to desk top url and immediately it’s redirecting to mobile site. can you please suggest me where I am doing wrong. I have created the full-site.php and placed this code and I have given the link to that file.

  7. Hi,

    I would like to use your plugin, however would it be possible to let me know how to have the redirect for mobiles and NOT iPads? Sorry, I can edit code if given some pretty big clues! 😉 Otherwise this would be a great feature to add in the future…i.e. the ability to choose the devices it redirects too since some new devices have such high pixel counts. thanks

    • Jeremy,

      The plugin will allow you to exclude tablets from the redirect. Check the PHP Mobile Plugin options.

  8. I setup the redirect for my mobile site and it gives me an error message saying that too many redirects occurred when I try to go to the website on my phone. Is that an error with my site or the plug-in?

Leave a Reply

Your email address will not be published. Required fields are marked *