How to prevent using your website content?

hello,

I’m really tiered with some hackers ( if I can say ) who points their websites to my website, so I’m using .htaccess to resolve this issue with the following code:

RewriteCond %{HTTP_HOST} ^hackerdomain.com [NC] 
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [L,R=301]

but the problem that if ( hackerdomain.com ) points his subdmain ( sub.hackerdomain.com ) to my website, I have also to add the same code to my .htaccess as following:

RewriteCond %{HTTP_HOST} ^sub.hackerdomain.com [NC] 
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [L,R=301]

SO there is no way to block totally any hacker to point its website / websites to my website with .htaccess or with other solution ??

Thanks in advance for your help.

Sorry, gents, but %{HTTP_HOST} is YOUR server, not the %{HTTP_REFERER}. Try changing that and see whether that makes a difference.

Edit: … and don’t forget to escape the dot character in your regex!

Regards,

DK

Thank you Raffles and Johen Betong, in fact I removed ^ as you said Raffles and everything is much better.

let me explain why they do that, in fact I have a lot of traffic in my website, so when someone point his website, his real goal will be to get traffic from google by using my website content.

Johen, I will visit the link and get back to you.

Maybe this thread will be helpful:
http://www.sitepoint.com/forums/showthread.php?p=4615985#post461598

.

The ^ character means “host must start with this”. The solution is just to remove that:

RewriteCond %{HTTP_HOST} hackerdomain.com [NC] 
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [L,R=301]

Are you sure this is the right move, though? If someone is visiting your site because they followed a link from a nasty site, it’s just going to look like your website doesn’t work. In fact, I’m not entirely sure what you’re trying to do, because it looks like you’re still redirecting them to your site (so it’s not really a redirection at all).

And finally, this should not be in the PHP forum, as it has nothing to do with PHP - this should be in the Apache configuration forum.