Go Back   vb.org Archive > vBulletin Article Depository > Read An Article > Programming Articles
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Block User Ip From Your (.htaccess)
Terminatoronly's Avatar
Terminatoronly
Join Date: Mar 2006
Posts: 313

 

Show Printable Version Email this Page Subscription
Terminatoronly Terminatoronly is offline 01-14-2007, 10:00 PM

Hi All,
well all of our forums have some bad members who want to do bad things in our forum so if you want to block him from cpanel he can access again so i thought of this thing blocking Member Ip From (htaccess) file.

What Does this do?
This Will Block The User IP Or Proxy If You Want From Viewing Your Site.


How It Works?
Make A New File Using Note Pad and put this code on it:
PHP Code:
<Limit GET HEAD POST>
order allow,deny
deny from 188.156.187
.***
deny from 188.155.187.***
allow from all
</LIMIT
This One Will Block The User Ip Who IS Using This IP:
PHP Code:
188.156.187.***
188.155.187.*** 
If You Want To Add More Ip's Just put it between:
PHP Code:
order allow,deny

allow from all 
After Adding This To Notepad Save it like this name:
Code:
htaccess.txt
then upload it using your ftp and name it to:
Code:
.htaccess
Also upload it in ASCII format.

Also You Can Add Domains To Block list .

Enjoy It
Reply With Quote
  #12  
Old 01-16-2007, 06:12 PM
Paul M's Avatar
Paul M Paul M is offline
 
Join Date: Sep 2004
Location: Nottingham, UK
Posts: 23,748
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Moved to articles section as this isn't actually a vbulletin modification.
Reply With Quote
  #13  
Old 01-16-2007, 10:41 PM
The Finman's Avatar
The Finman The Finman is offline
 
Join Date: Jun 2006
Posts: 78
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Terminatoronly View Post
Ok The Finman thanks for your reply i think that this thread is not good maybe i will report it

No problem as I am actually quite happy you brought this topic up.

As Forza stated, this really is a subject that needs discussion, since I believe the majority of web admins & owners (at least the ones I know) are running Apache.

The links I provided show the various ways that .htaccess can be applied.

Maybe a good place to start is the discussion of what does what and where, as my .htaccess code is slightly different, yet both work.

To block IPs and IP ranges, Terminatoronly uses...

Code:
<Limit GET HEAD POST> 
order allow,deny 
deny from 188.156.187.*** 
deny from 188.155.187.*** 
allow from all 
</LIMIT>

It appears that he is blocking not just an IP, but an IP range of 188.156.187.0 through 188.156.187.255.

If an IP is static (meaning the user's IP does not change - such as most cable & DSL) then one should simply use the specific IP address such as 188.156.187.244. Most "dial up" ISPs use dynamic IPs. Basically meaning that the user is assigned an IP from a block range available from that ISP while logged in. Upon log out, that user relinquishes that IP to the ISP and then it can be assigned to another user within that ISP's range.

I know I am probably covering well known knowledge, but sometimes I find that people don't realize just how much banning a block range can effect them and their guests.

Banning IP ranges can not only restrict users that may not have done anything to you, but you may also inadvertently knock out search engine spiders, crawlers, good bots, good users, Etc.

I really advise against banning IP ranges unless the problem is really that serious, and you have a reasonable idea of just how many other users you may knock out in the process...especially AOL users since AOL routes them through their own proxy servers, and banning even one range of AOL users you can take out a HUGE chunk of other visitors you may wish to have.

I use a variation of Terminatoronly's .htaccess file for banning IPs at the server base.

For example...

Quote:

Options +FollowSymlinks
RewriteEngine On
RewriteCond %{REMOTE_HOST} ^4\.245\.40\.88
RewriteRule ^.*$ http://www.send_them_somewhere_else.net/ [L,R]
RewriteCond %{REMOTE_HOST} ^86\.131\.16\.92
RewriteRule ^.*$ http://www.send_them_somewhere_else.com/ [L,R]
RewriteCond %{REMOTE_HOST} ^68\.48\.
RewriteRule ^.*$ http://www.yahoo.com/ [L,R]
RewriteCond %{REMOTE_HOST} ^71\.253\.249\.
RewriteRule ^.*$ http://www.send_them_somewhere_else.net/ [L,R]
RewriteCond %{REMOTE_HOST} ^68\.114\.48\.210
RewriteRule ^.*$ http://www.send_them_somewhere_else.net/ [L,R]
I have divert my immediate time to another project at the moment, but I will try and hop back in and explain the differences when I get a chance.

If someone else wants to hop in and list additional variations (other than mine or Terminatoronly), then please jump on in...as there is ALOT more variations than why are listed so far.

Also, here is another variation you might want to try, as it shows how two different uses for .htaccess files can be combined.

From my other post I showed you how to block (actually completely redirect ) people linking to your board or site that are not friendly.

Code:
Options +FollowSymlinks 
RewriteEngine On
RewriteCond %{HTTP_REFERER} ^http://www.troll_bulletin_board.com 
RewriteRule /* http://www.malicious_website.org [R,L]
RewriteCond %{HTTP_REFERER} ^http://troll_bulletin_board.com 
RewriteRule /* http://www.malicious_website.org [R,L]
Let's combine them real quick!

Code:
Options +FollowSymlinks 
RewriteEngine On
RewriteCond %{REMOTE_HOST} ^4\.245\.40\.88
RewriteRule ^.*$ http://www.send_them_somewhere_else.net/ [L,R]
RewriteCond %{REMOTE_HOST} ^86\.131\.16\.92
RewriteRule ^.*$ http://www.send_them_somewhere_else.com/ [L,R]
RewriteCond %{REMOTE_HOST} ^68\.48\.
RewriteRule ^.*$ http://www.yahoo.com/   [L,R]
RewriteCond %{REMOTE_HOST} ^71\.253\.249\.
RewriteRule ^.*$ http://www.send_them_somewhere_else.net/ [L,R]
RewriteCond %{REMOTE_HOST} ^68\.114\.48\.210
RewriteRule ^.*$ http://www.send_them_somewhere_else.net/ [L,R]
RewriteCond %{HTTP_REFERER} ^http://www.troll_bulletin_board.com 
RewriteRule /* http://www.malicious_website.org/ [R,L]
RewriteCond %{HTTP_REFERER} ^http://troll_bulletin_board.com 
RewriteRule /* http://www.malicious_website.org/ [R,L]
RewriteCond %{HTTP_REFERER} ^http://www.another_troll_bulletin_board.com 
RewriteRule /* www.another_bad_place.com/ [R,L]
RewriteCond %{HTTP_REFERER} ^http://another_troll_bulletin_board.com 
RewriteRule /* http://www.another_bad_place.com/ [R,L]
The above code actually combines the IPs and Referral Links .htaccess code variations, and then sends the trolls (via their IPs), and users/trolls/whatever (clicking through links to your board) to wherever you want to bounce them to.

First, before someone jumps in ans says I should have included "this" or excluded "that" in my .htaccess code above...I am not using the above (or attached) .htaccess file as the "be all and end all" of how to accomplish blocking IPs, IP Ranges, Referral Links, Etc.

I am simply showing you one possibility, just as Terminatoronly showed you his variation.

I've included a real good beginner's tutorial...


http://www.javascriptkit.com/howto/htaccess.shtml

as some of the Apache tutorials are about as much fun as watching paint dry.

http://httpd.apache.org/docs/1.3/howto/htaccess.html

Anyway, I'm sure a lot of Apache users already have a good grounding of what can be done with .htaccess, but maybe some may not be.

Also, there are a good deal of variations that can be used for different effects, and I would really encourage Apache users who already use .htaccess to list the way they use them and why.

I'll try and pop back in later...but yeah, I think it would be great if people would post their own uses and variations of htaccess files.
Attached Files
File Type: zip htaccess_example_file.zip (415 Bytes, 24 views)
Reply With Quote
  #14  
Old 01-17-2007, 11:34 AM
Terminatoronly's Avatar
Terminatoronly Terminatoronly is offline
 
Join Date: Mar 2006
Posts: 313
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Paul M View Post
Moved to articles section as this isn't actually a vbulletin modification.
oh sorry for posting in the wrong section
Reply With Quote
  #15  
Old 05-20-2007, 05:13 AM
karlm's Avatar
karlm karlm is offline
 
Join Date: Jul 2006
Location: England
Posts: 447
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by The Finman View Post
I'll try and pop back in later...but yeah, I think it would be great if people would post their own uses and variations of htaccess files.
The *.zip file in the above post appears to be corrupt.. I'm unable to view it, sadly... Iwas hoping to learn abit more than my current knowledge of .htaccess.

Thanks for the article, btw, I've been scouring the net for articles - and there was a gr8 one here the whole time LoL
Reply With Quote
  #16  
Old 07-08-2010, 03:33 AM
sinpin sinpin is offline
 
Join Date: Jan 2008
Location: Paradise
Posts: 29
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Terminatoronly View Post
Hi All,
well all of our forums have some bad members who want to do bad things in our forum so if you want to block him from cpanel he can access again so i thought of this thing blocking Member Ip From (htaccess) file.
Hey guys,
How to redirect banned users (with this method) to an customized error page?
Is this possible ?

thanks
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. The time now is 07:13 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.02180 seconds
  • Memory Usage 2,295KB
  • Queries Executed 21 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (5)bbcode_code
  • (3)bbcode_php
  • (5)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_article
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (6)post_thanks_box
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (6)post_thanks_postbit_info
  • (5)postbit
  • (1)postbit_attachment
  • (6)postbit_onlinestatus
  • (6)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • postbit_attachment
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete