的.htaccess维护多个IP的 [英] .htaccess Maintenance Multiple IP's

查看:260
本文介绍了的.htaccess维护多个IP的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用下面的code在我的.htaccess文件把我的网站置于维护。从本质上讲它的作用是重定向谁不是从一个特定的IP地址为.maintenance。子域名在那里我有一个维护页面了(因此让我在真正的网站进行测试)。我的问题是,如何将添加第二个IP地址到行:

 的RewriteCond%{REMOTE_ADDR}!^ 23 \ .254 \ 0.12 \ 0.43
 

让2 IP的才能通过?是它简单,只是将一个空间,并使用相同的格式与第一个? (对不起提前如果真的是这么简单,但我没有测试过,由于担心它可能会被工作,但真的不)。谢谢!

  ###################################### #############################
RewriteEngine叙述上
的RewriteBase /
的RewriteCond%{REMOTE_ADDR}!^ 23 \ .254 \ 0.12 \ 0.43
的RewriteCond%{REQUEST_URI}!^ /维修\ html的$
重写规则^(。*)$ http://maintenance.mysite.com [R = 307,L]
################################################## ##################
 

解决方案

只是增加一个的RewriteCond 来处理第二个IP地址应该是好的,像这样:

  RewriteEngine叙述上
的RewriteBase /
的RewriteCond%{REMOTE_ADDR}!= 23.254.12.43
的RewriteCond%{REMOTE_ADDR}!= 192.168.0.1
的RewriteCond%{REQUEST_URI}!^ /维修\ html的$
重写规则^(。*)$ http://maintenance.mysite.com [R = 307,L]
 

I am using the code below within my .htaccess file to place my site into maintenance. Essentially what it does is to redirect anyone who is NOT from a specific IP address to a .maintenance. subdomain where I have a maintenance page up (thus allowing me to perform testing on the real site). My question is, how would I add a second IP address to the line:

RewriteCond %{REMOTE_ADDR} !^23\.254\.12\.43

to allow 2 IP's to come through? Is it as simple as just putting a space and using the same format as the first one? (Sorry in advance if it really IS that simple, but I haven't tested it due to fear it may appear to be working but really not). Thanks!

###################################################################
RewriteEngine On
RewriteBase /
RewriteCond %{REMOTE_ADDR} !^23\.254\.12\.43
RewriteCond %{REQUEST_URI} !^/maintenance\.html$
RewriteRule ^(.*)$ http://maintenance.mysite.com [R=307,L]
####################################################################

解决方案

Just adding another RewriteCond to handle the second IP address should be fine, like so:

RewriteEngine On
RewriteBase /
RewriteCond %{REMOTE_ADDR} !=23.254.12.43
RewriteCond %{REMOTE_ADDR} !=192.168.0.1
RewriteCond %{REQUEST_URI} !^/maintenance\.html$
RewriteRule ^(.*)$ http://maintenance.mysite.com [R=307,L]

这篇关于的.htaccess维护多个IP的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆