Forum Moderators: DixonJones

Message Too Old, No Replies

.htaccess blocking

         

xplicit

4:10 am on Jun 10, 2003 (gmt 0)

10+ Year Member



i really need a good .htaccess blocking code ... i have a lot of people coming to my site that i don't want there ... but every .htaccess code i've used, either the people have been able to bypass or the code has produced an error 500. i specifically need a code that will block partial ips ... does anyone have any recommendations?

jdMorgan

4:44 am on Jun 10, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



xplicit,

Welcome to WebmasterWorld [webmasterworld.com]!

Your question is a little general...
The two main modules used to block unwelcome visitors on Apache are mod_access and mod_rewrite. Many server setups deny user access to mod_rewrite, but many allow access to mod_access.

mod_access code takes the form:
<Files *>
deny from 12.34.56.78
</Files>

and mod_rewrite code takes the form:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REMOTE_ADDR} ^12\.34\.56\.78$
RewriteRule .* - [F]

If both those types of code cause 500 Server errors on your server setup, then you'll need a better host!

You might want to take a look at your server error log after you get a 500 error; It often will tell you what the problem is.

If you mean "IP address ranges" - meaning more than one IP address - when you say "partial IPs," then that's fairly easy; You just leave off the last group of digits and any trailing "$" in the examples above.

Ref: Introduction to mod_rewrite [webmasterworld.com]

HTH,
Jim