.htaccess - Complex Apache Limit/SetEnvIf, allow all from domain except for IP -


i have following .htaccess:

<limit post>     setenvif host www.livedomain.com allow     setenvif remote_addr 1.1.1.1 allow     setenvif remote_addr 2.2.2.2 allow     setenvif remote_addr 3.3.3.3 allow     order deny,allow     deny     allow env=allow </limit> 

this .htaccess used on 2 domains. on www.livedomain.com want access. on www.stagingdomain.com want ips 1.1.1.1, 2.2.2.2, 3.3.3.3 have access.

this works fine.

now, on live site, want make change allow except 1 ip (let's 9.9.9.9).

i've tried doing this:

<limit post>     setenvif host www.livedomain.com allow     setenvif remote_addr 9.9.9.9 deny     setenvif remote_addr 1.1.1.1 allow     setenvif remote_addr 2.2.2.2 allow     setenvif remote_addr 3.3.3.3 allow     order deny,allow     deny     allow env=allow </limit> 

but doesn't work. have thought env variable overwritten 'deny' , final allow statement wouldn't apply. not case?

what's simplest way allow 1 domain except 1 ip in case?

you should use !varname unset or remove defined variable:

<limit post>     setenvif host www.livedomain.com allow     setenvif remote_addr 9.9.9.9 !allow     setenvif remote_addr 1.1.1.1 allow     setenvif remote_addr 2.2.2.2 allow     setenvif remote_addr 3.3.3.3 allow     order deny,allow     deny     allow env=allow </limit>  

read more setenvif here


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -