Welcome to WebmasterWorld Guest from 54.147.212.98

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

'Deny'-ing a Range of IP addresses

   
3:47 pm on Sep 26, 2012 (gmt 0)



HI:
I'm a newbie on this forum,
I run my three very small web sites from my home office using Apache 2.2.22 as my server.

I wish to 'deny' access to one of my sites to a *range* of addresses:

I have:

Order allow,deny
Allow from All
Deny from nnn. xxx.yy. ppp.qq.ss.tt etcetera

But, I wish to 'Deny' a *range* of IPs, e.g.,
Deny from nnn. (a Whole Region)
but 'allow' a certain few of the IPs in this region to be allowed.

In my dreams:
deny from nnn. Except for nnn.mm. AND. nnn.ppp.qq.ss AND etcetera

Can anyone tell me how to specify a Range of Denials please ?

Thanks,
-Mel Smith
3:57 pm on Sep 26, 2012 (gmt 0)

WebmasterWorld Senior Member wilderness is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



Here's a simple example:


RewriteEngine on
#deny acces Class a EXCEPT excluded (!) ranges
RewriteCond %{REMOTE_ADDR} ^137\.
RewriteCond %{REMOTE_ADDR} !137\.118\.232\. [OR]
RewriteCond %{REMOTE_ADDR} !137\.119\.
RewriteRule .* - [F]
4:17 pm on Sep 26, 2012 (gmt 0)



HI Wilderness:

I've never used (or had to use) the RewriteEngine. So, I'll have to read up on it to understand the syntax.

Thanks for the response

Now, I'll dig into the documentation.

-Mel Smith
Alberta, Canada
4:48 pm on Sep 26, 2012 (gmt 0)

WebmasterWorld Senior Member wilderness is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



FWIW mod_rewrite
4:53 pm on Sep 26, 2012 (gmt 0)



Hi Wilderness:
I've printed out a bunch of docs from apache.org on mod_rewrite and examples, and will read/study them today.

Thanks for the guidance !

-Mel Smith
12:59 pm on Sep 27, 2012 (gmt 0)

WebmasterWorld Senior Member wilderness is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



mel,
FWIW, I don't comprehend the entire mod_rewrite and/or Apache docs and I've used portions for more than a decade.

There are hundreds of examples of UA and IP restrictions

RewriteCond %{REMOTE_ADDR} [google.com]

There are many, many more examples for RewriteCond %{HTTP_USER_AGENT} [google.com]
6:58 pm on Sep 27, 2012 (gmt 0)



Hi Wildernes:
Yeh, I printed out a whole bunch of docs from Apache.org and was lots almost immediately (I'm only a very primitive user of Regex).

Bur, I went to your examples (especially, 'Deny and Redirect an IP) and will look over it carefully -- in the privacy of my bedroom :))

Thanks AGAIN,

-Mel Smith
Edmonotn, Canada and Mesa, Arizona