2012-10-02 34 views
0

所有我想用下面Nginx的重定向,除了我的IP地址

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

它重定向細做它從我的IP地址重定向的所有用戶,除了,在「網站下」的頁面,但贏得了」允許我的IP訪問該網站。任何幫助將不勝感激。

回答

0

下面應該工作:

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;} 
+0

完美,謝謝! – jamessy

0

這個怎麼樣

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; 

}