SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot
    Join Date
    Jul 2008
    Posts
    120
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    .htaccess, mobile version of site,

    can i configure .htaccess to direct browsers to a different css file based upon their browser type?

    That's the short question. The longer question is: how do I set up my .htaccess file to call a different css file based on mobile browsers?

    All I want to do create a 2nd version of a css file so that my site's content, when viewed on a mobile browser, calls /mobi/style.css instead of /style.css.

    I have the rewritecond statement for all the mobile browsers, and in fact I presently direct all mobile browser traffic to a designated static webpage, which you can see at tastyplacement . com which directs to tastyplacement . com/mobi.

    But if I could simply call a different css file, I could have the pages load as they normally would but with a different css file and thus an entirely different look for the website (narrower columns, no header navigation, ie., a stripped down version of the site with the main text intact).

    Can it be done?

  2. #2
    SitePoint Member
    Join Date
    Dec 2007
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    afaik, yes its possible not sure by htaccess or another script.
    Server Systems Administration NZ
    SSANZ.NET | Server Security | Hosting Systems
    Experienced, Professional & Available 24/7

  3. #3
    Floridiot joebert's Avatar
    Join Date
    Mar 2004
    Location
    Kenneth City, FL
    Posts
    823
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why not just apply whatever you have redirecting to a new HTML page, to the CSS instead ?

    It seems to me like you already have everything you need setup, but you just need to alter your RewriteRule pattern to apply only to style.css
    Maybe even just enclose the whole thing in a <Files> container that applies to style.css

  4. #4
    SitePoint Author silver trophybronze trophy
    wwb_99's Avatar
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    10,651
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Do you provide a way to get back? 2 of my three mobile devices (iPod touch, nokia e71) work fine with most full featured sites now. Neither of those devices is particularly uncommon . . ..

  5. #5
    SitePoint Zealot
    Join Date
    Jul 2008
    Posts
    120
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by joebert View Post
    Why not just apply whatever you have redirecting to a new HTML page, to the CSS instead ?
    Exactly what I was getting at...I have tested it manually and it sort of works. This site is a wordpress installation--otherwise I'd just duplicate the site in a subfolder.

    Here's what I have got so far:

    RewriteBase /
    RewriteEngine On
    RewriteCond %{HTTP_USER_AGENT} Windows\ CE [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} BlackBerry [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} NetFront [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} Opera\ Mini [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} Palm\ OS [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} Blazer [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} Elaine [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} ^WAP.*$ [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} Plucker [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} Nokia [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} iPhone [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} AvantGo [NC]
    RewriteCond $1 !^mobi
    RewriteRule ^(.*)$ /mobi/$1 [L]

    Does anyone know how to write the rewrite rule to call the file mobile-style.css instead of style.css.

    Is it this?:
    RewriteRule ^http://www.TastyPlacement.com/wp-content/themes/AmelieNEW/style.css$ http://www.TastyPlacement.com/wp-content/themes/AmelieNEW/mobile-style.css [L]


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
  •