Dream Master Dream Master - 1 year ago 75
Apache Configuration Question

htaccess use of Order Deny,Allow

I'm using Order Deny,Allow in my .htaccess file, without success. IP's I need to prevent access to are going right through with no troubles. I read that as of Apache 2.4 Order Deny,Allow would no longer work; first is that factual and second if so what has replaced it? I cannot access my httpd.conf file, so Require and Require not is not an option for me.

I only have access to .htaccess, how can I accomplish banning by ip or if no longer possible, redirecting by ip. Below is a snipit of my Order Deny,Allow if it matters. Thanks in advance!

Order Deny,Allow
Deny from 123.125.71.*
Deny from
Deny from some.domain.com
Allow from All

(as you can see, I'm attempting to block the same ip, in various formats but no matter the format, the traffic continues to go through.)

Answer Source

To push the undesired ip to 403 ,you can use the following rule :

RewriteEngine on

RewriteCond %{REMOTE_ADDR} ^00\.00\.00\.00$
 RewriteRule ^ - [R=403,L]

Replace with your undesired ip address.

To ban multiple ipaddress, you can add multiple conditions seprated by a [OR] flag to your rule :

RewriteEngine on

RewriteCond %{REMOTE_ADDR} ^00\.00\.00\.00$ [OR]
RewriteCond %{REMOTE_ADDR} ^00\.00\.00\.00$
 RewriteRule ^ - [R=403,L]
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download