.htaccess and sub-domains


I’m preventing hot-linking from my site. Issue is, I want to prevent from both my main portfolio AND sub-domain. Here’s what I wrote:

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www.)?site.com/.$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www.)?sub.site.com/.
$ [NC]
RewriteRule .(gif|jpg|swf)$ redirect.gif [R,L]

Now, I am capable of getting this to work for the main site (the first listed), but not for the sub.
Is there some lil’ extra step I should be taking?

Thanks in advance for all your replies.


A friendly bump to resolve this issue.

If this will help any, besides the main site (site.com), the second site (sub.site.com) contains my phpBB forum. Could it not be working due to the fact that the sub site is .php based?

I’ve been searching high and low, only to receive thousands of tutorials referring to only one site on one account. I have in my directory:

sub.site.com (php)
sub.test.com (php)



And I wish to prevent hotlinking on the first two, somehow using the one htaccess file. If there is an alternative way to disallow hotlinking to the sub, I’m open for suggestions (if within reason of my knowledge and easibility).


.htaccess files go in the document root (“Web directory”) or a directory in which a URL path has been mapped to using the Re-map Sub-dir panel.

One could try making a symlink to an .htaccess file.

:cool: Perl / MySQL / HTML+CSS


Hmm… this is gonna take some working on. Now, I’m receiving 500 Internal error.

There’s alot of different methods online I’m gonna test out on writing this up, I’ll give those a run. But, I had always thought the file was placed ‘outside’ the folder, where you see alias, postfix, etc, files. It worked for my main site, but not for the sub. And now that I moved it to both of those folders, I get errors.