Redirecting mobile devices with .htaccess breaks CSS

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!!
halfoffdrinksAsked:
Who is Participating?
 
ravenplConnect With a Mentor Commented:
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
 
halfoffdrinksAuthor Commented:
Thanks ravenpl!  Adding:

RewriteCond %{REQUEST_URI} !\.css$

Open in new window


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

From novice to tech pro — start learning today.