0

我所做的只是使用以下命令将所有用户(除了我的 IP 地址)重定向到“站点关闭”页面

 location / {
   rewrite (.*) /sitedown.php redirect;
    allow 94.12.147.139;
    index index.html index.php;
    try_files $uri $uri/ @handler;
    expires 30d;
}

它重定向很好,但也不允许我的 IP 访问该站点。任何帮助将不胜感激。

4

2 回答 2

1

以下应该有效:

location / {
  #this is the allow/deny/redirect bit
  allow 94.12.147.139;
  deny all;
  error_page 403 sitedown.php;  

  #regular site config when not denied
  index index.html index.php;
  try_files $uri $uri/ @handler;
  expires 30d; 
}

location /sitedown.php {allow all;}
于 2012-10-02T19:45:38.977 回答
1

这个怎么样

 location / {

    if($remote_addr != Your Ip) {
        rewrite ^ http://www.domain.com/sitedown.php;
    }

    index index.html index.php;

    try_files $uri $uri/ @handler;

    expires 30d;

}
于 2013-09-19T18:03:26.347 回答