• Revisiting Mobile Redirection Using .htaccess ReWrite Rules

    This article is out of date, check my latest code snippet here.
    Back in 2007 I wrote a post detailing a method for detecting and redirecting mobile browsers using .htaccess. Since then the mobile landscape has changed quite a bit: iPhone and Android have been released, the PDA market is all but dead and phones are better in general.

    My original post was based on a PHP script by Andy Moore. It’s worth noting that he has continued to update his script and now has a fancy little generator to help you create a PHP based redirect ruleset. Check out detectmobilebrowsers.mobi for more info.

    His solution will probably work for a lot of applications, but there are 2 main reasons I prefer using Apache’s rewrite rules to redirect mobile browsers:
    1) Application independent. By putting the rules in the root .htaccess file you can easily redirect traffic across multiple directories, independent of any webapp that might or might not be running in those directories.
    2) Faster. Placing the rewrite rules in apache’s httpd.conf file is potentially faster, than running the regexp in a php script for every request.

    Enough of that, here’s the updated ruleset.

    # don't apply the rules if you're already in the mobile directory, infintine loop
    # you'll want to test against the host if you're using a subdomain
    RewriteCond %{REQUEST_URI} !^/mobiledirectoryhere/.*$
    # if the browser accepts these mime-types, it's definitely mobile, or pretending to be
    RewriteCond %{HTTP_ACCEPT} "text\/vnd\.wap\.wml|application\/vnd\.wap\.xhtml\+xml" [NC,OR]
    # a bunch of user agent tests
    RewriteCond %{HTTP_USER_AGENT} "sony|symbian|nokia|samsung|mobile|windows ce|epoc|opera" [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} "mini|nitro|j2me|midp-|cldc-|netfront|mot|up\.browser|up\.link|audiovox"[NC,OR]
    RewriteCond %{HTTP_USER_AGENT} "blackberry|ericsson,|panasonic|philips|sanyo|sharp|sie-"[NC,OR]
    RewriteCond %{HTTP_USER_AGENT} "portalmmm|blazer|avantgo|danger|palm|series60|palmsource|pocketpc"[NC,OR]
    RewriteCond %{HTTP_USER_AGENT} "smartphone|rover|ipaq|au-mic,|alcatel|ericy|vodafone\/|wap1\.|wap2\.|iPhone|android"[NC]
    # put your rewrite rules here

    Text Version

    As you can see, the user agent list is a fair bit less verbose. I’ve been testing the ruleset on a very busy site, based on over 250k mobile site hits this set of rules is causing a lot fewer false positives, while not missing any significant number of mobile browsers.


  • 3 Myths About Mac OS X [Updated!]

    Years of switch ads and John Hodgman awesomeness have finally gotten to me. I bought a 15″ MacBook Pro. I’m living the iLife. It’s my first real Apple experience since the Apple IIe, overall I’m pretty impressed, though I have this sinking feeling that I’m not using OS X to it’s fullest potential.

    That said, there are a few major myths about the operating system that need to be busted.

    1. It’s easier to use
    For a long time, Macs (even before OS X) had the unfortunate distinction as the “dummy” computer, good for old people and computer illiterates. Because of this sterotype, I had assumed the the user-interface was somehow inherently easier to use. This is absoultely untrue.
    Some things are a little easier. Installing apps is a little easier, sometimes, depending on the installer. Systems preferences is a laid out a little better than the Windows control panels, especially Vista’s. Apps integrate with the OS a little better. Spotlight is pretty awesome. But in general, things are just different, no better or worse than Windows.

    A number of important apps/features are actually harder to use:

    • cmd vs ctrl: The OS X equivalent of the control key – in windows (and gnome for that matter) – is command. ctrl+z in windows, translates to cmd+z in osx. The issue here is keyboard layout. The cmd key is located right next to the spacebar. This makes any shift+cmd combination extremely difficult to pull off.
    • Finder Sucks!: Finder is just not a very good way to manipulate files. The main problem is the lack of an “up” button to navigate to the parent directory. Finder has a back button – “back” isn’t always “up.” Finder also has a dropdown which lists all the directories in the path, while this is a more efficient way to go navigate “up” 2 directories or more, it’s less efficient when you want to navigate up 1 directory – 2 clicks to use the dropdown vs. 1 click to use an “up” button.
      Another issue is the accordion directory interface you get in list view – 1 click opens the directory in the current view, 2 clicks opens the directory as your current view.
      The list view itself is also broken. There is no way to organize the list view to match the default windows list view. I.E. Directories at the top, files below, in alphabetical order.
      Don’t even get me started on the “save file” interface.
    • Menu Bar: While I think the top of the screen is actually the correct location for things like the clock and other indicators, the menu bar paradigm does not work well with multiple displays. When I open an app on my secondary display I have to go back to the primary display everytime I want to use the app’s menus. Really does not make any sense.
    • Dock: It’s kind of useless.
    • Alert Boxes: Application alerts (eg. “Are you sure you want to exit”) appear at the top of the app window, as opposed to the center of the screen. This is another minor UI mistake, imho.

    2. Security features are not annoying
    OS X warns me the first I open a file or run an app I’ve downloaded off the internet (even if i actually downloaded the file in an archive). Enough said.

    3. It doesn’t crash
    In a week of use I’ve had 2 or 3 (stable) apps crash, the OS froze and needed to be powercycled once. This is not a good start.

    UPDATE!:

    Setupmac.com has a solution to my issue with the up button.
    First, the keyboard shortcut ⌘↑ goes to the “enclosing folder.” I think this alone solves my problem!!
    Second, they also have a patch to add an up button to the finder toolbar.
    Link


  • iWatch. The iPhone Watch.

    LG just release a watch phone

    Allow me to present you with the iPhone watch.