Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 8 of 8
Like Tree1Likes
  • 1 Post By TheGAME1264

Thread: SItuational Mobile Website Redirection using PHP?

  1. #1
    Junior Member
    Join Date
    Feb 2014
    Posts
    2
    Member #
    38595

    Lightbulb SItuational Mobile Website Redirection using PHP?

    My first time posting here - actually registered just to ask this question!

    I am the go to "tech guy" at a restaurant that features live music and semi-formal dining.

    We recently obtained a mobile website from DudaMobile and it has been working quite well for us in most respects.

    The issue is this: The Calendar looks like garbage when rendered for mobile viewing. We decided to just link to the "full site view" for the Calendar link. That is a satisfactory solution. However, on the Calendar, there are links to Events for nearly every day. When clicking through these links it was rendering the page for mobile viewing, but it also looked like garbage. I called DudaMobile and they said there wasn't anything they could do to help me edit the output, so I settled for a cookie redirect that made it so once you left the mobile version through the calendar, you stay on the full site. I want users to be able to view the Calendar in full view, but then be easily able to return to the mobile version.

    I'm wondering if there is some way to tell if the user is trying to view a foo.com/Events/xxx.*** page, and if they are to direct them to the full site, but if they are mobile and viewing anything that ISN'T /Events/ then it shows the mobile version.

    I hope this is clear, and I hope even more that one of you bright-minded individuals has a solution for me!

  2.  

  3. #2
    Unpaid WDF Intern TheGAME1264's Avatar
    Join Date
    Dec 2002
    Location
    Not from USA
    Posts
    14,485
    Member #
    425
    Liked
    2783 times
    DudaMobile? I'm guessing someone has been talking to Google. That's usually their recommendation for a mobile site company. I've heard them speak twice at Google conferences so that's how I know of the company.

    I'm not sure how DudaMobile does the mobile redirect, but I'm guessing it uses one of .htaccess or web.config in some form. You'd need some kind of redirect rule that would say "the URL contains events and the HTTP Host contains mobile.yourdomain.com or however DudaMobile does it".
    Salvatore likes this.
    If I've helped you out in any way, please pay it forward. My wife and I are walking for Autism Speaks. Please donate, and thanks.

    If someone helped you out, be sure to "Like" their post and/or help them in kind. The "Like" link is on the bottom right of each post, beside the "Share" link.

    My stuff (well, some of it): My bowling alley site | Canadian Postal Code Info (beta)

  4. #3
    Junior Member
    Join Date
    Feb 2014
    Posts
    2
    Member #
    38595
    We got the mobile site for free as part of the deal for signing up with this company that handles our reservation system.

    They're doing something with JS in the <head> section of my main page.

    <script src="http://static.dudamobile.com/DM_redirect.js" type="text/javascript"></script>
    <script type="text/javascript">DM_redirect("http://m.foo.com");</script>
    I don't know if this is the right forum to be asking about cookies, but does this help anyone understand my issue more clearly?

  5. #4
    Unpaid WDF Intern TheGAME1264's Avatar
    Join Date
    Dec 2002
    Location
    Not from USA
    Posts
    14,485
    Member #
    425
    Liked
    2783 times
    I think I'm the closest thing you've got, dude. But here's my thought, having never done anything with DudaMobile...chances are you can do one of two things:

    1) Remove the JS files related to DudaMobile from your Events pages, probably by using a PHP if condition. e.g. (and I'm not a true PHP guy):
    Code:
    if (strpos($_SERVER['PATH_INFO'], 'Events') === false) {
        // put in the scripts here.
    }
    2) On the events pages, you can put a counter redirect in place to the full page like this:
    Code:
    if (strpos($_SERVER['HTTP_HOST'], 'm.') == 0) {
        // put in the redirect to your site here.
    }
    Hopefully that gives you a little guidance.
    If I've helped you out in any way, please pay it forward. My wife and I are walking for Autism Speaks. Please donate, and thanks.

    If someone helped you out, be sure to "Like" their post and/or help them in kind. The "Like" link is on the bottom right of each post, beside the "Share" link.

    My stuff (well, some of it): My bowling alley site | Canadian Postal Code Info (beta)

  6. #5
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,686
    Member #
    5580
    Liked
    716 times
    Does DudaMobile allow you to use PHP scripting in your pages?

    If so, the page extensions would either be .php or defined in your .htaccess file to process .html and .htm as .php

    For anyone viewing this that can use PHP, this works pretty good ...

    Code:
    <?php
    $useragent=$_SERVER['HTTP_USER_AGENT'];
    if(preg_match('/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i',$useragent)||preg_match('/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i',substr($useragent,0,4)))
    header('Location: http://detectmobilebrowser.com/mobile');
    ?>
    Otherwise, you can see what other methods they offer, like javascripting ...

    http://detectmobilebrowsers.com/


  7. #6
    Unpaid WDF Intern TheGAME1264's Avatar
    Join Date
    Dec 2002
    Location
    Not from USA
    Posts
    14,485
    Member #
    425
    Liked
    2783 times
    You just keep that regular expression handy for situations like this, Max? Do you pull out the regex for a US zip code out of your wallet and hand it out at parties, too?
    If I've helped you out in any way, please pay it forward. My wife and I are walking for Autism Speaks. Please donate, and thanks.

    If someone helped you out, be sure to "Like" their post and/or help them in kind. The "Like" link is on the bottom right of each post, beside the "Share" link.

    My stuff (well, some of it): My bowling alley site | Canadian Postal Code Info (beta)

  8. #7
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,686
    Member #
    5580
    Liked
    716 times
    Interesting idea, but there are 43,000 zipcodes in the U.S.
    I think your zipcode database is the way to go.

    But you're in Canada?
    There are 845,990 postal codes in Canada ... whoa! Do you have the database for that?


  9. #8
    Unpaid WDF Intern TheGAME1264's Avatar
    Join Date
    Dec 2002
    Location
    Not from USA
    Posts
    14,485
    Member #
    425
    Liked
    2783 times
    At least the vast majority of it. There's a regex specifically for Canadian postal codes as well (it's not letter/number/letter/space/number/letter/number, either, as some letters are excepted).

    I have to do some work on that site at some point in the not-too-distant future, though.
    If I've helped you out in any way, please pay it forward. My wife and I are walking for Autism Speaks. Please donate, and thanks.

    If someone helped you out, be sure to "Like" their post and/or help them in kind. The "Like" link is on the bottom right of each post, beside the "Share" link.

    My stuff (well, some of it): My bowling alley site | Canadian Postal Code Info (beta)


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Tags for this Thread

All times are GMT -6. The time now is 05:13 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com