Solved

Redirecting mobile devices with .htaccess breaks CSS

Posted on 2012-03-17
2
551 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
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

In my time as an SEO for the last 2 years and in the questions I have assisted with on here I have always seen the need to redirect from non-www urls to their www versions. For instance redirecting http://domain.com (http://domain.com) to http…
If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

776 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