EquinoxMatt
EquinoxMatt

Reputation: 83

htaccess for allowing domain to serve only images

For the life of me I can't work this out.

I have one main domain, hosting a busy website. (domain1.com)

I have a second domain, which uses content from domain #1. To link the images on this second site I want to use images.domain2.com.

images.domain2.com has been set up as an alias on domain1.com.

So now if someone goes to images.domain2.com they see domain1.com content, I don't want people to see this. (duplicate content).

I want it to work though, if someone requests images.domain2.com/images/image1.jpg.

Does this make sense?

Upvotes: 0

Views: 505

Answers (1)

Venu
Venu

Reputation: 7279

Try this

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^images\.domain2\.com [NC] 

    RewriteCond %{REQUEST_FILENAME} !\.(gif|jpe?g|png|js|css|swf|php|ico|txt|pdf|xml)$
    RewriteRule ^(.*)$ domain2.com/$1 [L]
</IfModule>

Upvotes: 1

Related Questions