简体   繁体   中英

htaccess Allow only internal IP

RewriteCond %{REMOTE_ADDR} !=173.220.70.101 [OR,NC]
RewriteCond %{REMOTE_ADDR} !=173.220.70.102
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]

I would like to have a or statement for two IP address

the old version worked for one IP not sure why this isn't working anymore.

Use:

RewriteCond %{REMOTE_ADDR} !=173.220.70.101
RewriteCond %{REMOTE_ADDR} !=173.220.70.102
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]

Without [OR]...

Allowing only 173.220.70.1 and 173.220.70.2

RewriteCond %{REMOTE_ADDR} !^173.220.70.[1-2]$
RewriteRule ^.* - [F]

Allowing any IP except 173.220.70.1 and 173.220.70.2

RewriteCond %{REMOTE_ADDR} ^173.220.70.[1-2]$
RewriteRule ^.* - [F]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM