I have an .htaccess redirect script for my mobile detection:
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} (iphone|android|nokia|BlackBerry) [NC]
RewriteCond $1 !^mobile/ [NC]
RewriteRule ^(.*)$ http://www.example.com/mobile/ [R=301,L]
When I get redirected to the mobile site, my links don’t work that point to:
www.example.com/img0.jpg
If I navigate directly to the site by browsing to:
www.example.com/mobile/
the links work perfectly.
What am I missing in the .htaccess file that is affecting this linking?
Thanks.
EDIT:
I used your script and then added this into the mobile directory, not exactly sure why it works, but it does!
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?mobile\.example\.com$
RewriteCond %{REQUEST_URI} example.com/mobile
RewriteRule ^(.*)$ /mobile/$1 [L]
Try this: