Allow multiple IPs to access Wordpress Site Admin via .htaccess

与世无争的帅哥 提交于 2020-01-04 02:55:47

问题


I currently have a wordpress site that is being upgraded and I have a maintenence redirect setup in the .htaccess file.

I can allow my own IP access the site and admin but how can I allow multiple IPs access for the other editors to also have access.

I'm currently using :

     
     RewriteEngine on
     RewriteCond %{REMOTE_HOST} !^123.456.789.101
     #RewriteCond %{REMOTE_ADDR} !^123.456.789.101
     RewriteCond %{REQUEST_URI} !/maintanence.html$ [NC]
     RewriteCond %{REQUEST_URI} !.(jpe?g?|png|gif) [NC]
     RewriteRule .* /maintanence.html [R=302,L]
    
    

回答1:


The answer might be a bit late but:

 RewriteCond %{REMOTE_HOST} !(123\.456\.789\.101|123\.456\.789\.102|123\.456\.789\.103)

works well.




回答2:


Well you wanted IPs not hosts, so make sure to do that. Then chain them together using your intended logic:

RewriteCond %{REMOTE_ADDR} !^127\.0\.0\.1$
RewriteCond %{REMOTE_ADDR} !^127\.0\.0\.2$
RewriteCond %{REMOTE_ADDR} !^127\.0\.0\.3$
RewriteRule .* /maintenance.html [R=302,L]


来源:https://stackoverflow.com/questions/8602399/allow-multiple-ips-to-access-wordpress-site-admin-via-htaccess

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!