Forward all IPs except these whites

I want to protect some subdomains from the public. Restriction should be made against the IP whitelist. An endless loop due to redirection is not a problem since it is not a www domain.

I tried this http://discussions.apple.com/message.jspa?messageID=2411725 but couldn't get it working.

However i tried this first

RewriteEngine on
RewriteCond %{REMOTE_ADDR} !^123\.45\.67\.89$ [OR]
RewriteCond %{REMOTE_ADDR} !^213\.45\.67\.89$
RewriteRule ^/.* http://www.mydomain.com [R]

.. but did not work.

What am I doing wrong?

+3
source share
2 answers

You need to combine the directives RewriteCondwith AND instead of OR, as you want to redirect if both conditions are true (for this, the IP address is neither X nor Y). So try the following:

RewriteEngine on
RewriteCond %{REMOTE_ADDR} !^123\.45\.67\.89$
RewriteCond %{REMOTE_ADDR} !^213\.45\.67\.89$
RewriteRule ^ http://www.example.com/ [R]
+2

, Apache Allow Deny. <VirtualHost> , , :

<Location />
    Order allow,deny
    Allow from all
    Deny from 123.45.67.89
    Deny from 213.45.67.89
</Location>

403 () , www. , ,

ErrorDocument 403 http://www.example.com
+4

Source: https://habr.com/ru/post/1703251/


All Articles