Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 557
  • Last Modified:

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!!
0
halfoffdrinks
Asked:
halfoffdrinks
1 Solution
 
ravenplCommented:
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

Featured Post

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now