I have tooled my htaccess to prevent hotlinking. If you try to hotlink to : http://mysite.com/img/bla.jpg Code (markup): it works fine, the linking is blocked and a replacement image is sent. BUT, if you hotlink to : http://subdomain.mysite.com/img/bla.jpg Code (markup): Hot linking protection doesn't work. Any ideas ? Thanks
It's REALLY long, it was generated by my cpanel. Here is an example RewriteCond %{HTTP_REFERER} !^http://mysite.net/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://mysite.net$ [NC] RewriteCond %{HTTP_REFERER} !^http://subdomain.mysite.net/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://subdomain.mysite.net$ [NC] RewriteCond %{HTTP_REFERER} !^http://myspace.com/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://myspace.com$ [NC] RewriteRule .*\.(jpe?g|gif|bmp|png)$ /sad.jpe [L] Code (markup): I have a few subdomain. I'm thinking the code generated by cpanel is very inefficient since it's very repetitive. I'm sure there is just one simple change I'm missing.
You're right it is quite inefficient. I believe you could replace all those RewriteConds that have mysite in them with this one: Change the (dot) for a . as the system prevents me from posting "links". If that doesn't work, then there could be a redirection somewhere before this one that would prevent it from working.
Hrm.. thanks for the code, it seems to cut down on the repetitiveness but hotlinking is still working for my subdomains. Very strange ! Thanks
I assume that .htaccess in in the web root for only mysite.net ? Also assuming you are on a shared host, put the .htaccess in the web root for your subdomains. Also, the be on the safe side, take out the slash from the end of that pattern, like so: RewriteCond %{HTTP_REFERER} !^http://(.+\.)?mysite\.com [NC]
Thanks a lot krt. It seems that if each web root for the sub domains doesn't have the filtering htaccess in it hot linking will still work.