Author - Robert Popovic

Founder and Technical Director of LERO9, a web agency specializing in Magento and WordPress design and development.

I launched Magebase in April, 2010 and am its editor and contributor. My main topics of interest are Magento development, customization and how to get the most out of Magento with the least amount of headache.

More Info » Follow me on Twitter »

Reader Comments (58)

  1. Sam
    August 14, 2010 at 10:10 pm /

    Nice simple explanation – this really hasn’t been documented so well by the Magento team.

    How would this work for IE6? What would the user agent be in that case? I think it would be nice to just redirect IE6 users to one of the standard themes, maybe the blank one, and show everyone else your custom theme – would save a lot of time and effort – I know this can be done with conditional statements but this would be even easier and require no extra markup.

  2. clark
    December 4, 2010 at 3:42 am /

    Just wanted to share with everyone that i was able to get this to work on my iphone but not the iPad by taking out the “Mobile” exception from this list.

    The final matched expressions would be: iPhone|iPod|BlackBerry|Palm|Googlebot-Mobile|Mobile|mobile|mobi|Windows Mobile|Safari|Android|Opera Mini

    1. Ashraf
      February 2, 2011 at 10:05 pm /

      Just put “iP” for iPhone, iPad, iPod… it works for me.

    2. clark
      February 3, 2011 at 3:11 am /

      Sorry, looking at my original post I realized I made an error. The only exception that needs to be taken out of the list is the “Mobile” exception. The one with the capital “M”.

      The (revised) final exception would be: iPhone|iPod|BlackBerry|Palm|Googlebot-Mobile|mobile|mobi|Windows Mobile|Safari|Android|Opera Mini

      Notice the “Mobile” is not in there.

      I have this working on Enterprise Edition 1.8 and

      1. Marco
        September 10, 2012 at 6:04 am /

        Taking out Mobile also excludes Nokia Belle browser compatibility!

  3. chris ward
    December 19, 2010 at 2:22 pm /

    thanks for the post, with google clogged up with info on the new magento mobile app it’s been hard to find a decent how to guide, for me an optimized mobile site will work better than an app and is a lot cheaper.

  4. Luca
    March 15, 2011 at 10:49 am /

    First of all, sorry for my english, i added
    al the list of exceptions. I tested in my Nokia C5 and works fine

  5. Piet
    May 24, 2011 at 1:48 am /

    Can I be the one moaning “It doesn’t work”??? You’d think it’s quite straightforward to add the exeption, but somehow something goes wrong… Are there any reasons why this would fail? Tested on a Desire (Android) and iPhone.

  6. Aria
    June 24, 2011 at 3:07 am /

    Hi Robert,
    Thanks for very nice explanation. I was looking for this forever.
    I’ve done exactly the same as above and cleared the cache but still no result on my windows mobile (HTC HD). I tried opera mini 5, 9, 10 , WM IE.
    Thanks for your help.

  7. Aria
    June 24, 2011 at 11:38 pm /

    Hi Robert, I’ ve indeed a non-default package . First it didn ’ t matter if I use default or non-default one . Obviously if you have an inactive non-default package you still need to add exception overall under package section (template /skin/layout/ default).
    I use ‘Windows CE’ and it works fine with different browsers on my device.
    It’s now working many thanks to you.

  8. KidA
    July 2, 2011 at 1:28 am /

    I was wondering if there is a way to allow for people to opt BACK to the regular site if they dont want to use the mobile site or have it forced on them for that experience? Do you know how to do this?

    1. clark
      July 2, 2011 at 2:03 am /

      +1 for me!

      I am wondering the same thing. Does anyone know how to do this? Is this possible with the user agent detection magento uses?

  9. capnhud
    July 9, 2011 at 1:04 am /

    Just came across this article while looking the functionality to serve a mobile version of magento.

    It would seem that this would be possible to use Detect Mobile Browser to accomplish what you are trying to do?

  10. toshi
    September 5, 2011 at 11:46 pm /

    I’ve been looking for information about how to include Android phones and exclude Android tablets. Google says you should exclude Android if the user agent doesn’t include ‘mobile’ in it.

    Is it possible to detect “android” with “mobile”? If I include “Mobile” in then it also detect iPad.
    iPad running iOS 3.2 user agent string
    Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10

  11. Geoff
    September 22, 2011 at 11:06 am /

    This does not work for me. I have tried a whole bunch of combinations but nothing works (no theme change). I’ve tried something like this ( and it still doesn’t work. I’ve tried to change the Package name and it at least switches but does not pick up ANY css or images???

    I’m so confused…is it because I’m on a subdomain????

    /skin/frontend/pro/iphone is where the package sits…

  12. vipul
    September 27, 2011 at 2:30 am /

    i have used the expression iPhone|iPod|BlackBerry|Palm|Googlebot-Mobile|mobile|mobi|Windows Mobile|Safari|Android|Opera Mini|Nokia|SymbianOS as exception and iphone as a value..i have setup the iphone theme. But my problem is that It WORKS WITH NOKIA PHONE BUT SHOWS THE FULL WEBSITE VERSION IN iPhone .
    Please help

  13. Ron Kruger
    October 21, 2011 at 8:12 pm /

    Hey, Thanks so much Robert! You saved my day.

  14. vipul
    October 21, 2011 at 9:36 pm /

    Thanks a lot Robert …works fine for me now 🙂

  15. Harsh
    November 25, 2011 at 1:44 am /

    Thanks a lot Robert , working like a charm 😉

  16. Peter Svegrup
    Peter Svegrup
    December 2, 2011 at 5:11 am /

    Hi Robert and everyone else,

    Big thanks for this one and the ‘mobilize’ tutorials. Very clear and as someone as already noted, very handy as there almost none around of the same quality.

    I have a problem relating to the UAs in the expression as both iPad (Safari desktop iPad mode) and desktop Safari both show the iphone theme with the suggested string. I tried taking out ‘Mobile’ as Clark noted above but that didn’t help. Could it be an update in UAs that are now creating this problem or is the Safari simulation mode not to trust?

    Thanks a lot in advance


  17. Türchen 06: Magento Design Exceptions mit Varnish « Das Entwickler-Blog für Magento, eCommerce und Shops –

    […] oder verschiedene Devices im Cache halten will? Ein solcher Anwendungsfall sind z.B. die sog. Design Exceptions in Magento, mit denen sich abhängig vom User-Agent (Browser) das Theme unter System/Konfiguration/Web ändern […]

  18. Adam Kochanowicz
    Adam Kochanowicz
    January 14, 2012 at 10:32 am /

    I’m taking over a magento project on which previous developers had already worked.

    Should there be references to the custom stylesheets in the head.phtml file at all? It seems like you would only set that within the backend.

    Also, I got the above working in a limited way, but it loads a mobile page for BOTH desktop and mobile browsers. It doesn’t seem to detect one or the other.

  19. rakesh purohit
    rakesh purohit
    February 15, 2012 at 11:09 pm /

    Hi friends,

    i need to use diffrent template like:iphone for mobile browser and use default template for system browser, what exactly i should do, i used this solution but it’s not working,
    are you sure if i use this solutiob my problem will short out?
    my mobile template name ie mobileredlily and name of my default template is redlily, after putting exception in default tab in value section i have to put template name or what???
    i cant understand please help me

    1. Geoff
      February 16, 2012 at 9:10 am /


      Make sure you’re following the instructions above well. Also, in my case, I was missing the entire design template directory. Make sure you have both! (check out

  20. Sergio Giudici
    April 20, 2012 at 9:00 am /

    I have an issue. I’m using a custom package which is located in


    The only way I have to make this theme work is going into my System/Design and Add Design Change otherwise it will stick to the default design and I think is supposed to be that way.
    The problem is that when I followed your instructions and I added these exceptions, technically nothing happened.
    It only changes the order of the very top menu (My Account | My Wishlist | My Cart | Checkout | Log In) and the bottom menu and that’s all, everything else looks the same.
    Can you help me out to figure what I’m doing wrong?

  21. Kiến thức công nghệ » How To “Mobilize” Your Magento Site for iPhone, Android, Mobile Commerce

    […] we recently learned, it’s pretty straight forward to redirect your mobile visitors to a mobile-optimized theme, the […]

  22. polo
    September 5, 2012 at 8:35 pm /

    Thank you, It’s useful to me.

  23. Jena
    November 1, 2012 at 11:23 am /

    Thank you, Its work for me as well.
    It wasn’t working initially, As either i may not read it properly or i was trying wrong. I think it would be helpful to someone that if i say how did i make it.

    System > Configuration > General > Design -> Package and Theme sections

    Enter the following value’s in to the all “Template, Skin, Layout, and Default” Section (Not only the Default section)

    Matched Expression: iPhone|iPod|BlackBerry|Palm|Googlebot-Mobile|Mobile|mobile|mobi|Windows Mobile|Safari Mobile|Android|Opera Mini
    Value: iphone

    1. Nick
      November 30, 2012 at 10:10 am /

      For mobile matching I like to use I just think it catches more phones and it is updated too. Since they don’t have just a plain regular expression option i just modified one of the others a little and it seems to be working great.

      Matched Expression: (?i)((android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|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)
      Value: iphone

  24. Andrew
    November 8, 2012 at 12:51 pm /

    I was able to so this on a default install but was unsuccessful in seeing a change on a customized Magento site using the same technique. Anything I should be considering that I might have missed?

    1. Andrew
      November 9, 2012 at 6:43 am /

      I should also add that I’m actually using Magento Enterprise ver.

  25. martyn
    December 1, 2012 at 12:41 am /

    Having the same problem as Andrew – It switched fine if the default template is chosen but as soon as I swap to another template then it doesn’t work?

  26. Frank
    December 7, 2012 at 5:35 pm /

    Is it possible to do a mobile version of my website that useMagento community ver. or I should upgrade to achieve that goal?


  27. Frank
    December 8, 2012 at 10:49 am /

    I’m a newbie at this but what are the spec, dimension of the template I should let my designer do for the mobile theme?

  28. Peter Pieters
    June 30, 2013 at 10:54 pm /

    I’ve enabled the Magento iPhone Theme but it seems there is some kind of bug with Google Analytics. After the enabling all mobile visitors are provided with the iphone theme but they’re NOT TRACKABLE anymore in Google Analytics

  29. Dane
    October 3, 2014 at 5:38 am /

    Worth noting that this is a regex match. It is also case sensitive. You can see the code at


    I wanted to try to get as many mobile browsers as possible, but exclude Android tablets and iPads. Assuming that Android tablets don’t have ‘Mobile’ in the UA string, I am trialling this one:

    iP(hone|od)|(?=.*\bAndroid\b)(?=.*\b(m|M)obile\b).*|BlackBerry|IEMobile|Windows Mobile|Windows Phone|NetFront|Silk-Accelerated|(hpw|web)OS|Fennec|Minimo|Opera M(obi|ini)|Blazer|Dolfin|Dolphin|Skyfire|Zune

    Also worth mentioning that you could split them into multiple exception lines to make it easier to understand or use with complex regex.

    The other really cool thing that is often overlooked is that if you theme is mostly responsive anyway, or you just wanted to include a separate CSS file, you don’t have to overload the entire theme, just the skin or specific template files. While it’s simple it isn’t immediately obvious that you don’t always need an entirely different theme.

    There’s a really good resource for UA pattern matching here:

    1. Carlos
      January 30, 2015 at 8:24 am /

      Thank you Robert for the great post….Dane this really helped me…Thank you

  30. bhagavath
    April 28, 2015 at 1:54 am /

    Hi guys,

    I am using Magento version i am planing to use IPhone theme for mobiles. But it is not working for this version. I follwed all procedures. Could u guys help me for this issue. Thanks in advance.

  31. How To Create A Custom Layout In Magento | MY NEWS

    […] Magento Design Exceptions Explained Or How To Serve … – Founder and Technical Director of LERO9, a web agency specializing in Magento and WordPress design and development. I launched Magebase in April, 2010 and am its …… […]

  32. Leandro
    February 25, 2016 at 2:23 am /

    Who knows how to set this exception via PHP in Magento?

  33. Nadia
    June 22, 2016 at 6:00 am /


    I have this question, I can use magento from my cellphone? is a htc10, sorry i know that is a stupid questions, bit I’m so new in this format. Sorry for that.


Add a Comment & Join the Discussion

Insert small snippets of code by using [code]{your_code_here}[/code]
For larger code blocks please use and paste your link.

You may also use the following HTML in your comment: <a href="" title=""> <abbr title="">
<acronym title=""> <blockquote cite=""> <cite> <em> <strike> <strong>