Question

I am new to htaccess configuration but I have been reading and researching for awhile.

I have a mobile subdomain which I wish to fetch images located on my main domain. I am unsure as how to get it to work. My current code is:

RewriteCond %{HTTP_HOST} ^m\.\.website\.com [NC]
RewriteRule  ^/avatar/(.*)$ http://www.website.com/avatar/$1 [P]

The image directory looks like this:

/avatar/thumbnail/image.jpg
/avatar/preview/image.jpg
/avatar/full/image.jpg

However, when I try to access m.website.com the images do not load.

Can anyone tell me what I am missing.

Any feedback would be greatly appreciated.

Was it helpful?

Solution

Remove leading slash from your rule and also take out extra DOT from host name condition:

RewriteCond %{HTTP_HOST} ^m\.website\.com [NC]
RewriteRule  ^(avatar/.*)$ http://www.website.com/$1 [P,L]

This assumes you have mod_proxy enabled and working.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top