htaccess的阻止所有IP的,如果它们被阻止重定向到一个页重定向、htaccess、IP

2023-09-02 20:34:34 作者:依稀记忆

所以我阻止所有IP的除了那些名单上,所以我怎么能重定向人到一个新的网站,如果他们阻止?

So I am blocking all ip's except the ones on a list, so how can I redirect people to a new site if they're blocked?

推荐答案

我的假设是,你是封锁IP的使用允许/拒绝。我不相信,你可以指定一个重定向规则工作,对被拒绝的IP的,你告诉服务器拒绝它们的连接顾左右而言他。

My assumption is that you are blocking ip's using allow/deny. I do not believe that you are able to specify a redirect rule to work on the denied ip's as you have told the server to reject their connections outright.

相反,你会想用RewriteEngine叙述做一个重定向。如果你不熟悉我提供了下面的例子将重定向所有IP的除了72.14.204.99和72.14.204.100到example.org的语法:

Instead you are going to want to use the RewriteEngine to do a redirect. In case you are unfamiliar with the syntax I have provided the following example which will redirect all ip's except for "72.14.204.99" and "72.14.204.100" to "example.org":

RewriteEngine on
RewriteCond %{REMOTE_ADDR} !^72.14.204.99$
RewriteCond %{REMOTE_ADDR} !^72.14.204.100$
RewriteRule ^ http://www.example.org/ [R]
 
精彩推荐
图片推荐