Forum Moderators: phranque

Message Too Old, No Replies

Ban site visitors from specific domains or URLs

Can you ban visitors who come from specific domains or URLs

         

richards1052

8:46 am on Aug 22, 2005 (gmt 0)

10+ Year Member



I'm plagued periodically by floods of abusive comments originating at various forum sites. I know you can deny via by IP address. But why can't you deny by domain or URL or can you?

Periodically my blog is linked in <objectionable> forums and I get abusive comments coming from specific threads at the site. I'd like to be able to ban anyone from commenting (or visiting?) who comes to my site from a specific url or domain. Let's say my commenter is coming to my post from www.exampleforum.com/discussions/thread.php?t=331697
I'd like to either be able to ban someone from that specific URL or else from the exampleforum.com domain.

I don't know the technical issues involved in this & perhaps it's not feasible. But it would sure work wonders for me in preventing blog assaults.

To be clear, I don't mean that I want to ban commenters who use a specific domain or url in their comment ID info. I want to somehow connect the URL or domain they CAME FROM to preventing a visit or comment.

To those who may suggest using blog comment moderation for this purpose, my settings are currently not working & I can't use them in this way (it's a long story).

I don't think you can do this w. cPanelx. I know you can deny access by IP. But I don't believe you can deny access by domain...or can you?

[edited by: jdMorgan at 1:18 pm (utc) on Aug. 22, 2005]
[edit reason] Removed specifics. [/edit]

richards1052

10:00 am on Aug 22, 2005 (gmt 0)

10+ Year Member



UPDATE: I found this thread ( [webmasterworld.com...] ) which answers most of my question. It suggests using this mod_rewrite rule (to ban 2 domains):

RewriteCond %{HTTP_REFERER} example\.com [OR]
RewriteCond %{HTTP_REFERER} anotherdomain\.com
RewriteRule .* - [F]

My question is--if unwanted visitors are coming from a specific thread within a forum site is there a way to be more specific in the domain ban. Instead of banning 'example.com' can I ban 'example.com/threads'?

The reason for my wanting to do this is that my abusive visitors are coming only from the forum portion of this site and I don't see a need (yet) to ban anyone from this entire site fr. visiting my blog.

[edited by: jdMorgan at 1:19 pm (utc) on Aug. 22, 2005]
[edit reason] examplified. [/edit]

jdMorgan

1:16 pm on Aug 22, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



My question is--if unwanted visitors are coming from a specific thread within a forum site is there a way to be more specific in the domain ban. Instead of banning 'example.com' can I ban 'example.com/threads'?

Yes, just add it onto the strings in the code you show above.

Escaping rules apply; You must escape characters which have special meanings to the regular-expressions parser by preceding them with a "\". In this case, you're likely to need to escape literal periods (as already shown above), and the "?" that separates any query strings from the URL if you are blocking from specific forums threads in a dynamically-generated forum.


RewriteCond %{HTTP_REFERER} exampleforum\.com/discussions/thread\.php\?t=331697

Jim

richards1052

10:46 pm on Aug 22, 2005 (gmt 0)

10+ Year Member



Jim: I just tried using the solution suggested in the linked thread & I'm getting a 500 error whether or not I include the Follow SymLinks command:

RewriteCond %{HTTP_REFERER} example\.com 
RewriteRule .* - [F]

or

Options +FollowSymlinks
RewriteCond %{HTTP_REFERER} #*$!\.com
RewriteRule .* - [F]

Also, when I add this rewrite rule then the domain forwarding mod_rewrite rules also in my .htaccess file stop working.

When I remove the domain banning code above, then everything goes back to normal. Can you think of how this may be causing a conflict & what I might do to resolve it?

Don't know if this has anything to do w. anything but I noticed that the .htaccess file commands have lost all formatting & they just run on w/o line breaks. Since the commands in the above code are formatted with line breaks could this be the problem or part of it?

jdMorgan

12:38 am on Aug 23, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What's your server error log say?
Are you using a custom 403 ErrorDocument? (If so, you will have to exclude it from the rule)

Jim