SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Member
    Join Date
    Sep 2004
    Location
    Mty
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question user agent for windows phones - htaccess mobile redirect

    Hello,

    Does anyone know the proper value for windows phones user agent to handle mobile redirect using htaccess?

    example, I use this for iphone.

    RewriteCond %{HTTP_USER_AGENT} ^.*iPhone.*$

    But it seems/looks that there are many options for Windows phones (iemobile, Windows/Phone, etc.)

    Thanks in advance for the help!

    Jesus
    Never give up!

  2. #2
    Barefoot on the Moon! silver trophy Force Flow's Avatar
    Join Date
    Jul 2003
    Location
    Northeastern USA
    Posts
    4,606
    Mentioned
    56 Post(s)
    Tagged
    1 Thread(s)
    You can find a massive list here: http://www.useragentstring.com/pages...20Browserlist/

    But it doesn't look like there's much on there for Windows phones.

    It looks like this is what the Windows 8 phone user agent will look like: http://blogs.windows.com/windows_pho...s-phone-8.aspx

    However, it's usually a best to target browser features and screen resolutions, rather than user agents, as there are so many various of user agents. Plus, user agents can be spoofed
    Visit The Blog | Follow On Twitter
    301tool 1.1.5 - URL redirector & shortener (PHP/MySQL)
    Can be hosted on and utilize your own domain

  3. #3
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,834
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    You need to remember that Internet Explorer, Firefox, Opera and Safari all allow the useragent to be set to anything at all and so any of those four browsers running on a computer can identify itself as any type of phone. That not only makes it really easy to test any code that you write that makes use of the useragent - and it also shows how pointless such tests are.

    Targetting viewport size is generally the best way of determining whether the device is using a mobile phone sized display but you can't detect that on the server at all.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  4. #4
    SitePoint Member
    Join Date
    Sep 2004
    Location
    Mty
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you Force Flow and felgall for your answers.

    I'll try to take a look at the viewport port option as it makes more sense. I'll try to post my code here once I figure this out.

    Thanks again!

    Jesus
    Never give up!

  5. #5
    Foozle Reducer ServerStorm's Avatar
    Join Date
    Feb 2005
    Location
    Burlington, Canada
    Posts
    2,699
    Mentioned
    89 Post(s)
    Tagged
    6 Thread(s)
    Quote Originally Posted by Jesus View Post
    Thank you Force Flow and felgall for your answers.

    I'll try to take a look at the viewport port option as it makes more sense. I'll try to post my code here once I figure this out.

    Thanks again!

    Jesus
    Jesus
    As Fegall and ForceFlow both recommended that you review Cascading Style Sheets ( CSS) media queries.
    ictus==""

  6. #6
    SitePoint Author silver trophybronze trophy
    wwb_99's Avatar
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    10,633
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by felgall View Post
    You need to remember that Internet Explorer, Firefox, Opera and Safari all allow the useragent to be set to anything at all and so any of those four browsers running on a computer can identify itself as any type of phone. That not only makes it really easy to test any code that you write that makes use of the useragent - and it also shows how pointless such tests are.
    I totally agree that focusing on browser capabilities is a vastly superior method of handling these sorts of things in general. That said, I do think that if someone is actively monkeying with browser settings to the point they are simulating being another browser or device then they have crossed the line of voiding the warranty -- they are actively lying to you.

    I'll also note viewports can be tricky in this day and age now that we are seeing very high pixel density displays and such, often operated with imprecise fat fingers.

  7. #7
    SitePoint Author silver trophybronze trophy
    wwb_99's Avatar
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    10,633
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    [dupe redacted]

  8. #8
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,834
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by wwb_99 View Post
    That said, I do think that if someone is actively monkeying with browser settings to the point they are simulating being another browser or device then they have crossed the line of voiding the warranty -- they are actively lying to you.
    Of course Microsoft are the ones who started using that field to lie when they started claiming that their browser was Mozilla (which was the identifier in the useragent to identify Netscape). No browser since then has ever done anything but lie in that field as they all claim to be Netscape with the Mozilla reference at the start of the field. If ALL browsers actively lie in that field then why shouldn't someone change the value in the USER agent to identify the browser the way they want - after all that's what all the browsers do anyway.

    Also most browsers give you a choice of which of their competitors useragents you want to use to identify their browser. Safari running on Windows has a setting to identify itself as iPhone and Chrome has a similar setting for identifying itself as Android. Those are settings provided by Apple and Google as a part of the browser setup.

    So the liars here are Microsoft, Apple and Google. So they are the people you should be telling to stop monkeying with the settings and let the USER decide how they want to identify THEIR browser - it is after all called a USER agent and so I should be the one choosing the value to use for it in my browsers and not Microsoft, Apple or Google offering values that pretend to be Netscape.

    Also if I were to set the useragent in my browsers to "Steve's Microsoft Browser", "Steve's Apple Browser" and "Steve's Google Browser" then unlike the supplied useragents I am not lying as that would be an accurate description of what they are - it wouldn't match any of the utterly stupid useragent tests but then the only valid use for testing that field is to gather statistics on how many people use which lying useragent.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  9. #9
    SitePoint Author silver trophybronze trophy
    wwb_99's Avatar
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    10,633
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    I'm not sure your beef with Microsoft makes much sense here -- why is it wrong to serve the pages to users in the way they ask for them? Is it my job as a developer to somehow re-divine what browser people are using even if they are telling me they are using a different one intentionally?

    Also most browsers give you a choice of which of their competitors useragents you want to use to identify their browser. Safari running on Windows has a setting to identify itself as iPhone and Chrome has a similar setting for identifying itself as Android. Those are settings provided by Apple and Google as a part of the browser setup.
    Those options make loads of sense -- loads easier to test webapps with desktop browsers. Sometimes you want to fake it. Especially with Safari for windows which is almost purely a tool for developers to test things with safari to make the web better for apple customers on apple devices.

    So the liars here are Microsoft, Apple and Google. So they are the people you should be telling to stop monkeying with the settings and let the USER decide how they want to identify THEIR browser - it is after all called a USER agent and so I should be the one choosing the value to use for it in my browsers and not Microsoft, Apple or Google offering values that pretend to be Netscape.

    Also if I were to set the useragent in my browsers to "Steve's Microsoft Browser", "Steve's Apple Browser" and "Steve's Google Browser" then unlike the supplied useragents I am not lying as that would be an accurate description of what they are - it wouldn't match any of the utterly stupid useragent tests but then the only valid use for testing that field is to gather statistics on how many people use which lying useragent.
    Early versions of MSIE did use Mozilla's user agent string but MSIE has always identified itself as well. See http://www.nczonline.net/blog/2010/0...-agent-string/ for a bit of history here.

    Moreover, I think the IETF doesn't agree with your definition of USER agent. Section 14.43 of the RFC states:

    The User-Agent request-header field contains information about the user agent originating the request. This is for statistical purposes, the tracing of protocol violations, and automated recognition of user agents for the sake of tailoring responses to avoid particular user agent limitations. User agents SHOULD include this field with requests. The field can contain multiple product tokens (section 3.8) and comments identifying the agent and any subproducts which form a significant part of the user agent. By convention, the product tokens are listed in order of their significance for identifying the application.
    Nowhere do they say it is an end-user adjustable header.


Tags for this Thread

Bookmarks

Posting Permissions

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