Solved

Redirecting mobile devices with .htaccess breaks CSS

Posted on 2012-03-17
2
554 Views
Last Modified: 2012-03-18
Hey Experts,

I am trying to redirect mobile devices using the following code:

RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]
RewriteCond %{HTTP_HOST} !^halfoffdrinks.com/staging/mobile/
RewriteRule ^(.*)$ http://www.halfoffdrinks.com/staging/mobile/ [L,R=302]

Open in new window


It works great but it seems to also be redirecting my CSS calls or something?  The CSS breaks when I have that code in my .htaccess file.  If I remove it, the CSS works again.  Can someone please help me out?

Thank you!!
0
Comment
Question by:halfoffdrinks
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 43

Accepted Solution

by:
ravenpl earned 500 total points
ID: 37734567
Maybe You should exclude the css files from redirecting?
Like You already excluding the
> RewriteCond %{HTTP_HOST} !^halfoffdrinks.com/staging/mobile/
Add
RewriteCond %{REQUEST_URI} !\.css$
0
 

Author Comment

by:halfoffdrinks
ID: 37736319
Thanks ravenpl!  Adding:

RewriteCond %{REQUEST_URI} !\.css$

Open in new window


... did the trick!  Works great now :)  Thanks a lot!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Hi, in this article I'm going to teach you how to run your own site, and how to let people in (without IP). I'll talk about and explain each step... :) By the way, everything in this Tutorial is completely free and legal. This article is for …
In this article we will discuss all things related to StageFright bug, the most vulnerable bug of android devices.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question