Greenguy's Board


Go Back   Greenguy's Board > Blogs and Blogging
Register FAQ Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
Old 2008-12-15, 01:36 AM   #1
NY Jester
ICQ:147*079*406
 
NY Jester's Avatar
 
Join Date: Oct 2007
Location: Rock*ME*Hardplace
Posts: 2,996
Send a message via ICQ to NY Jester Send a message via AIM to NY Jester
htaccess/hotlinking for WP

Was hoping to find an easy way to hotlink protect my blog(s) from a few domains..with the ability to add more if needed and then in turn sending that traffic to a url of my choice.

Thanks in advance.
__________________
The Sexy Side of Porn
NY Jester is offline   Reply With Quote
Old 2008-12-15, 03:24 AM   #2
cd34
a.k.a. Sparky
 
cd34's Avatar
 
Join Date: Sep 2004
Location: West Palm Beach, FL, USA
Posts: 2,396
There are two ways to do it.

1) Block everything unless you specifically allow it -- this probably doesn't play well with the nature of blogs, but, the code would be:

Code:
RewriteEngine on
# leave this line in allow empty referrers, remove to disallow empty referrers
RewriteCond %{HTTP_REFERER} !^$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(.*@)?([a-z0-9-]+\.)*yourdomain\.com(:[0-9]+)?(/.*)?$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(.*@)?([a-z0-9-]+\.)*yourseconddomain\.com(:[0-9]+)?(/.*)?$ [NC]
RewriteRule .*\.(asf|mpg|mpeg|wmv|avi|rm|gif|jpeg|jpg|png|zip)$ - [NC,F,L]
You would just add in lines with the domains you choose. A slightly faster method would be to combine the regexp lines and do something like:

Code:
RewriteEngine on
# leave this line in allow empty referrers, remove to disallow empty referrers
RewriteCond %{HTTP_REFERER} !^$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(.*@)?([a-z0-9-]+\.)*(yourdomain\.com|yourseconddomain\.com)(:[0-9]+)?(/.*)?$ [NC]
RewriteRule .*\.(asf|mpg|mpeg|wmv|avi|rm|gif|jpeg|jpg|png|zip)$ - [NC,F,L]
Alternatively, to reverse the conditions and block specific domains:

Code:
RewriteEngine on
RewriteCond %{HTTP_REFERER} hotmail|google [NC]
RewriteRule .* http://url.to/go/to.html [F,L]
Since you really don't know where your blog is going to be syndicated, you will need to watch your logs and probably use the second method.
__________________
SnapReplay.com a different way to share photos - iPhone & Android
cd34 is offline   Reply With Quote
Old 2008-12-15, 11:48 AM   #3
Mr Spock
You can now put whatever you want in this space :)
 
Mr Spock's Avatar
 
Join Date: Nov 2006
Location: Vulcan
Posts: 695
Does this always work , I am getting a ton of traffic from asktiava which I want to redirect , I have this code in my htaccess:

Code:
RewriteEngine on

RewriteCond %{HTTP_REFERER} ^http(s)?://(www\.)?sex4free.co.il/heb_htm/cat/babes.htm/.*$ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http(s)?://(www\.)?fode-me.com/.*$ [NC,OR]
RewriteCond %(HTTP_REFERER) ^http(s)?://(www\.)?http://www.buterbrod.com/.$[NC,OR]
RewriteCond %(HTTP_REFERER) ^http(s)?://(www\.)?http://www.superzeta.it/.$[NC,OR]
RewriteCond %(HTTP_REFERER) ^http(s)?://(www\.)?http://www.sexonabanheira.com/.$[NC,OR]
RewriteCond %(HTTP_REFERER) ^http(s)?://(www\.)?http://80.64.8.170/.$[NC,OR]
RewriteCond %(HTTP_REFERER) ^http(s)?://(www\.)?http://www.ananasik.com/.$[NC,OR]
RewriteCond %(HTTP_REFERER) ^http(s)?://(www\.)?http://www.asktiava.com/search/.$[NC,OR]
RewriteCond %(HTTP_REFERER) ^http(s)?://(www\.)?http://www.iij4u.or.jp/.$[NC,OR]
RewriteRule .* http://www.avoidhomeforeclosureblog.com [R,L]

 

order allow,deny
deny from 89.18.179.48
allow from all
however it doesn't seem to work any they are still getting through , what am I doing wrong

Last edited by Mr Spock; 2008-12-15 at 11:51 AM..
Mr Spock is offline   Reply With Quote
Old 2008-12-15, 01:39 PM   #4
NY Jester
ICQ:147*079*406
 
NY Jester's Avatar
 
Join Date: Oct 2007
Location: Rock*ME*Hardplace
Posts: 2,996
Send a message via ICQ to NY Jester Send a message via AIM to NY Jester
Thanks for the reply CD - so to block out one domain (at the time being) Coudl I set up htaccess like this?
Code:
RewriteEngine on

RewriteCond %{HTTP_REFERER} badsite\.com [NC]
RewriteRule .* http://url.to/go/to.html [F,L]
__________________
The Sexy Side of Porn
NY Jester is offline   Reply With Quote
Old 2008-12-15, 01:42 PM   #5
NY Jester
ICQ:147*079*406
 
NY Jester's Avatar
 
Join Date: Oct 2007
Location: Rock*ME*Hardplace
Posts: 2,996
Send a message via ICQ to NY Jester Send a message via AIM to NY Jester
Mr Spock, Im not a code guru or anything but it appears with your example, you're adding the http and the www twice? maybe remove the "http://www." from the domain string and see if that works? Perhaps only use the "asktiava.com/search/" part.
__________________
The Sexy Side of Porn
NY Jester is offline   Reply With Quote
Old 2008-12-15, 02:11 PM   #6
cd34
a.k.a. Sparky
 
cd34's Avatar
 
Join Date: Sep 2004
Location: West Palm Beach, FL, USA
Posts: 2,396
Yes NY Jester, that snippet would work for banning 1 domain.

Code:
RewriteCond %(HTTP_REFERER) ^http(s)?://(www\.)?http://www.asktiava.com/search/.$[NC,OR]
this will actually look for http://http://www.asktiava as the referrer which is probably not what you are seeing

as NY Jester says:

Code:
RewriteCond %(HTTP_REFERER) ^http(s)?://(www\.)?asktiava.com/search/[NC,OR]
I would get rid of the .$ at the end as it would force a match of 1 character -- regexp is left matched and would basically say that this needs to be anchored to the left. Same thing about the http(s)? that means that the url could be http:// or https:// the (www\.)? means that the www. is optional.
__________________
SnapReplay.com a different way to share photos - iPhone & Android
cd34 is offline   Reply With Quote
Old 2008-12-15, 06:15 PM   #7
Mr Spock
You can now put whatever you want in this space :)
 
Mr Spock's Avatar
 
Join Date: Nov 2006
Location: Vulcan
Posts: 695
Quote:
Originally Posted by cd34 View Post
Yes NY Jester, that snippet would work for banning 1 domain.

Code:
RewriteCond %(HTTP_REFERER) ^http(s)?://(www\.)?http://www.asktiava.com/search/.$[NC,OR]
this will actually look for http://http://www.asktiava as the referrer which is probably not what you are seeing

as NY Jester says:

Code:
RewriteCond %(HTTP_REFERER) ^http(s)?://(www\.)?asktiava.com/search/[NC,OR]
I would get rid of the .$ at the end as it would force a match of 1 character -- regexp is left matched and would basically say that this needs to be anchored to the left. Same thing about the http(s)? that means that the url could be http:// or https:// the (www\.)? means that the www. is optional.
Changed it as you suggested , but if I click the link on asktiava.com to my site it doesn't redirect?
Mr Spock is offline   Reply With Quote
Old 2008-12-15, 08:51 PM   #8
cd34
a.k.a. Sparky
 
cd34's Avatar
 
Join Date: Sep 2004
Location: West Palm Beach, FL, USA
Posts: 2,396
Are you sure your .htaccess is being parsed? what is a url on that other site that is supposed to redirect based on your rule?

can you give me the query you use from the remote site? perhaps something in the url or the way they pass it to your site is erasing the referrer.
__________________
SnapReplay.com a different way to share photos - iPhone & Android
cd34 is offline   Reply With Quote
Old 2008-12-16, 12:18 AM   #9
Mr Spock
You can now put whatever you want in this space :)
 
Mr Spock's Avatar
 
Join Date: Nov 2006
Location: Vulcan
Posts: 695
This is the search query on asktiava.com:

http://www.asktiava.com/search/?p=10...awna+lenee&nc=


If I click on this link to my site it doesn't redirect like it should.

http://www.myfree-porn.com/free-gall...-ibp/free.html

Here is the contents of my htaccess:

Code:
AddType php-cgi .html .htm

RewriteEngine on
RewriteCond %{HTTP:Accept-Language} (zh) [NC]
RewriteRule .* http://www.avoidhomeforeclosureblog.com [R,L]

RewriteEngine on
RewriteCond %{HTTP_REFERER} ^http(s)?://(www\.)?sex4free.co.il/heb_htm/cat/babes.htm/.*$ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http(s)?://(www\.)?fode-me.com/.*$ [NC,OR]
RewriteCond %(HTTP_REFERER) ^http(s)?://(www\.)?buterbrod.com/.$[NC,OR]
RewriteCond %(HTTP_REFERER) ^http(s)?://(www\.)?superzeta.it/.$[NC,OR]
RewriteCond %(HTTP_REFERER) ^http(s)?://(www\.)?sexonabanheira.com/.$[NC,OR]
RewriteCond %(HTTP_REFERER) ^http(s)?://(www\.)?80.64.8.170/.$[NC,OR]
RewriteCond %(HTTP_REFERER) ^http(s)?://(www\.)?ananasik.com/[NC,OR]
RewriteCond %(HTTP_REFERER) ^http(s)?://(www\.)?asktiava.com/search/[NC,OR]
RewriteCond %(HTTP_REFERER) ^http(s)?://(www\.)?iij4u.or.jp/[NC,OR]
RewriteRule .* http://www.avoidhomeforeclosureblog.com [R,L]

order allow,deny
deny from 89.18.179.48
allow from all
Mr Spock is offline   Reply With Quote
Old 2008-12-16, 12:47 AM   #10
cd34
a.k.a. Sparky
 
cd34's Avatar
 
Join Date: Sep 2004
Location: West Palm Beach, FL, USA
Posts: 2,396
do you have any .htaccess files down below the one in your top directory?

if so, do they contain:

RewriteOptions inherit

in them?

If they don't, they replace the existing rewrite rules

also, your rules that end with .$ won't match much of anything -- you need them to either be .*$ or remove the .$ at the end.
__________________
SnapReplay.com a different way to share photos - iPhone & Android
cd34 is offline   Reply With Quote
Old 2008-12-17, 01:15 PM   #11
Mr Spock
You can now put whatever you want in this space :)
 
Mr Spock's Avatar
 
Join Date: Nov 2006
Location: Vulcan
Posts: 695
I changed the htaccess using the coding you gave Nyjester as follows

Code:
RewriteEngine on
RewriteCond %{HTTP_REFERER} asktiava.com [NC]
RewriteRule .* http://avoidhomeforeclosureblog.com [F,L]
When I click on the link on asktiava.com it gives a 403 error

What do I need to change to direct it to http://avoidhomeforeclosureblog.com
Mr Spock is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:48 PM.


Mark Read
Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
© Greenguy Marketing Inc