Reputation:
I need to block certain ip addresses on my website preferably with .htaccess methods. Can someone help me? I request that i be given some sort of URL or code examples here thank you!
Upvotes: 0
Views: 35
Reputation: 29521
I need to block certain ip addresses on my website preferably with .htaccess methods.
You can indicate which addresses you wish to block using RewriteCond %{HTTP_REFERER}
.
Working Example:
# BLOCK VISITORS REFERRED FROM GOOGLE.COM
RewriteCond %{HTTP_REFERER} ^https?://([a-z0-9-]+\.)?google\.com [NC]
RewriteRule .* - [F]
The example above uses a regular expression, so it will block:
https://
or http://
google.com
The [F]
flag means Forbidden
. The server will return a 403 Forbidden Error
.
Upvotes: 1
Reputation: 2975
deny from ip_address
should work
Edit: add link http://www.htaccess-guide.com/deny-visitors-by-ip-address/
Upvotes: 1