Give help. Get help.

  • Anonymous
    # April 18, 2013 at 6:51 am

    How can i automatically redirect users if they are on a desktop/laptop to a different URL.

    # April 18, 2013 at 6:56 am

    Isn’t it usually done the other way round?

    If they are on mobile send them to a specific mobile site?

    # April 18, 2013 at 7:00 am

    you can use user agent detection with php on the serverside or with javascript on the client side.
    With php the users user agent is stored in


    you can go with regex or strpos and testing for the devices you want and redirect with


    Respsonsive design is always better though

    # April 18, 2013 at 7:06 am

    @paulie_d i Guess i could put up the desktop site and redirect to mobile if on mobile. So either way could work.

    @pixelgrid That sounds kinda hard and i don’t know PHP or JavaScript.

    # April 18, 2013 at 7:16 am

    you can find many scrips using php online

    just for the record im posting an .htaccess solution too

    RewriteCond %{HTTP_USER_AGENT} ^.*iPad.*$
    RewriteRule ^(.*)$ [R=301]

    this one is for ipad redirection only

    # April 18, 2013 at 7:19 am

    Include the Class in your project. If on WordPress that would be in your functions.php file.

    Then just:

    $detect = new Mobile_Detect();

    if ($detect->isMobile()) {

    If you want the opposite just use the logical operator Not `!`.

    if (!$detect->isMobile()) {

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.