Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with rewrite rule

Status
Not open for further replies.

rye8261

Technical User
Jul 6, 2003
359
US
Is there a way to have a rewrite rule block certain domains or IP's from your site? I believe the "hotlink protection" built into cpanel blocks all except for what you allow but I'd like it the other way.

There is a domain that is scraping all of my content and placing it on their site. I'd like to block their IP or site from having access to my server. I have been in touch with their host about this and they have 24 hours to have it removed but I'd still like to have this functionality if it arises again.

Please can anyone help create this rule. I have no idea how to do it.

---------------------------------------
- Free General Web Directory, Free Web site submissions.
- Free General Web Directory, Free Web site submissions.
 
Hi

Oops. Sorry, confused the image theft with the request flood. We have to block based on the referrer, not the remote address.

This example from Apache protects against hot linking from any address. You can easily modify it if you want to block only that single bad site.
Code:
SetEnvIf Referer "^[URL unfurl="true"]http://www.example.com/"[/URL] local_referal
[gray]# Allow browsers that do not send Referer info[/gray]
SetEnvIf Referer "^$" local_referal
<Directory /web/images>
   Order Deny,Allow
   Deny from all
   Allow from env=local_referal
</Directory>

Feherke.
 
I'm sorry, I'm very new to all this.

The person is stealing images from several different directories, that's why I though htaccess would be the best if I could just block his domain or IP.

I'm not sure what IPTables is, I'll look into that.

feherke - Would I have to do your suggestion for every directory he is stealing from?

---------------------------------------
- Free General Web Directory, Free Web site submissions.
- Free General Web Directory, Free Web site submissions.
 
According to the people that manage my server the methods mentioned above block sites by IP address, not by referring site. That is why they told me to look for a htaccess method.

So back to the original, anyone have any idea on how to do this with htaccess?

---------------------------------------
- Free General Web Directory, Free Web site submissions.
- Free General Web Directory, Free Web site submissions.
 
Hi

rye8261 said:
The person is stealing images from several different directories, that's why I though htaccess would be the best if I could just block his domain or IP.
No, not that guy personally steals your images, he use his visitors to do that. So you have to block not his address, but the requests referred by his address.
rye8261 said:
I'm not sure what IPTables is
The best firewall solution. While its integration with the kernel is deep, it works only with Unix or Unix-based operationg systems. You need to have superuser privileges to use it.
rye8261 said:
feherke - Would I have to do your suggestion for every directory he is stealing from?
Not necessary. I do not know how are your directories spread, but you may put it in all image directories parent.
core.html said:
Enclose a group of directives that apply only to the named file-system directory and sub-directories
rye8261 said:
According to the people that manage my server the methods mentioned above block sites by IP address, not by referring site.
Correct. I was not enough thoughtful when I answered first. My second answer is the relevant one.
rye8261 said:
That is why they told me to look for a htaccess method.
Using the rewrite engine or the Apache core functionalities, both can be done in .htaccess files too.
rye8261 said:
So back to the original, anyone have any idea on how to do this with htaccess?
Put the code from my second answer into the .htaccess file in the highest level directory from the document root, where you have access.

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top