Link to home
Start Free TrialLog in
Avatar of dresdena1
dresdena1

asked on

Subdomain Images Not Loading properly

EE,
I created a subdomain for a website: m.mysite.com
I am using an htaccess file to detect if a visitor is mobile, if yes they are redirected to m.mysite.com if not they go to www.mysite.com

I didn't want to have to upload images to the mobile subdomain, I wanted to call them directly from the main site (www.) using http://www.mysite.com/image

The problem is that the images are loading on my desktop computer  (the links are correct/no broken links), but on my cellphone (and anyone else that has tested it) the images are not loading unless they are either: in the subdomain (without the http request) or called from a different domain altogether. Images called from www.mysite.com will not load on the cellphone.

I called tech support and while they were not able to directly help me, they felt it might be the .htaccess file. They found the same thing. Images loaded on desktops but not on cellphones.

I have very little understanding of this, but is there anything in the following that could be causing the problems?

RewriteEngine on
rewritecond %{http_host} ^mysite.com [nc]
rewriterule ^(.*)$ http://www.mysite.com/$1 [R=301,L]

AddType text/html .shtml .html .htm
AddHandler server-parsed .shtml .html .htm

# Check if this is the noredirect query string
RewriteCond %{QUERY_STRING} (^|&)noredirect=true(&|$)
# Set a cookie, and skip the next rule
RewriteRule ^ - [CO=mredir:0:%{HTTP_HOST},S]

# Check if this looks like a mobile device
# (You could add another [OR] to the second one and add in what you
#  had to check, but I believe most mobile devices should send at
#  least one of these headers)
RewriteCond %{HTTP:x-wap-profile} !^$ [OR]
RewriteCond %{HTTP:Profile}       !^$ [OR]
RewriteCond %{HTTP_USER_AGENT} "iPhone|iPad|iPod" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} BlackBerry [NC,OR]
RewriteCond %{HTTP_USER_AGENT} Android [NC,OR]
RewriteCond %{HTTP_USER_AGENT} googlebot-mobile [NC]
# Check if we're not already on the mobile site
RewriteCond %{HTTP_HOST}          !^m\.
# Check to make sure we haven't set the cookie before
RewriteCond %{HTTP:Cookie}        !\smredir=0(;|$)
# Now redirect to the mobile site
RewriteRule ^ http://m.mysite.com%{REQUEST_URI} [R,L]


ErrorDocument 404 /notfound.html

Any help would be greatly appreciated.
dresdena1
Avatar of dresdena1
dresdena1

ASKER

EE,
As a follow up comment to this question. When I remove the redirect section of the htaccess file the images load on the mobile browser just fine.

dresdena1
ASKER CERTIFIED SOLUTION
Avatar of ahoffmann
ahoffmann
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you for the response.
While I was waiting, I found http://detectmobilebrowsers.com/ and downloaded the Apache file and it is working correctly.
Thank you again.