Reputation: 175
All I'm trying to do it redirect all users, apart from my ip address, to a "site down" page using the following
location / {
rewrite (.*) /sitedown.php redirect;
allow 94.12.147.139;
index index.html index.php;
try_files $uri $uri/ @handler;
expires 30d;
}
It redirects fine but won't allow my IP to access the site either. Any help would be grateful.
Upvotes: 0
Views: 4915
Reputation: 5728
How about this
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;
}
Upvotes: 1
Reputation: 10546
the following should work:
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;}
Upvotes: 1