Serving images from subdomains


I’ve got a dev site, and a prod site. The dev site is a subdomain of, while the prod site has its own fully hosted domain.

I’m looking to move images from the core site to a subdomain. For prod, I will create a subdomain, serving images for from I expect that this will not be a problem.

OTOH, I was not allowed to create a subdomain of the testing site (i.e. As such, I created a new parallel subdomain, (note the ‘i’ at the end of mydevsite) and moved my images there.

As one would hope, hotlinking is prevented (presumably from any domain other than a subdomain of the domain in question). But I thought I could override that in the .htaccess file in

Here is what I tried:

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www.)?$ [NC]
RewriteRule .
.(gif|jpg|jpeg|bmp|png)$ - [F,NC]

Am I doing something wrong, or is serving images from another domain just not possible given DH’s configuration?


There’s nothing in place by default to restrict hotlinking. If you can’t embed your images right now, then there’s something else wrong with them…


Yeah, I figured that out… I was misinterpreting the 404s, and I was not actually redirecting my image requests

I think this is what I should be doing, but it doesn’t seem to be working:

RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www.)? [NC]
RewriteRule .(jpg|jpeg|png|gif|bmp)$$1 [R=301,L]


I got it

RewriteCond %{REQUEST_URI} ^/images
RewriteRule .(jpg|jpeg|png|gif|bmp)${REQUEST_URI} [R=301,L]