Is there a way to do it with a 301?<br><br><div class="gmail_quote">On Sun, Oct 17, 2010 at 12:11 PM, Igor Sysoev <span dir="ltr"><<a href="mailto:igor@sysoev.ru">igor@sysoev.ru</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On Sun, Oct 17, 2010 at 12:00:09PM -0400, Ilan Berkner wrote:<br>
<br>
> Thank you, I actually resolved it by:<br>
><br>
> location / {<br>
> allow 1.1.1.1;<br>
> deny all;<br>
> error_page 403 = @redirect_towww;<br>
> }<br>
><br>
> location @redirect_towww<br>
> {<br>
> rewrite ^(.*) <a href="http://www.primarydomain.com" target="_blank">http://www.primarydomain.com</a>$1 permanent;<br>
> }<br>
<br>
</div>error_page 403 <a href="http://www.primarydomain.com" target="_blank">http://www.primarydomain.com</a>$request_uri;<br>
<br>
However, you can not set 301 code.<br>
<div class="im"><br>
> On Sun, Oct 17, 2010 at 11:28 AM, helen <<a href="mailto:nginx-forum@nginx.us">nginx-forum@nginx.us</a>> wrote:<br>
><br>
> > On Sun, 17 Oct 2010 10:36:42 -0400, Ilan Berkner wrote:<br>
> ><br>
> > [...]<br>
> > > The above code works as expected, but I would like to do something<br>
> > like<br>
> > > this:<br>
> > ><br>
> > > location / {<br>
> > > if not 1.1.1.1 or 1.1.1.2 or 1.1.1.3 do a 301 redirect to<br>
> > > <a href="http://www.domain.com" target="_blank">www.domain.com</a>(with request uri)<br>
> > > }<br>
> > ><br>
> > > is this possible?<br>
> ><br>
> > Use the nginx geo module to set up a boolean-style variable - say,<br>
> > $internal_ip. Then put something like this in the server block for your<br>
> > test site:<br>
> ><br>
> > if ($internal_ip != 1) {<br>
> > rewrite ^ <a href="http://your.public.site/" target="_blank">http://your.public.site/</a> permanent;<br>
> > }<br>
> ><br>
> > helen<br>
> ><br>
> > Posted at Nginx Forum:<br>
> > <a href="http://forum.nginx.org/read.php?2,141550,141558#msg-141558" target="_blank">http://forum.nginx.org/read.php?2,141550,141558#msg-141558</a><br>
> ><br>
> ><br>
> > _______________________________________________<br>
> > nginx mailing list<br>
> > <a href="mailto:nginx@nginx.org">nginx@nginx.org</a><br>
> > <a href="http://nginx.org/mailman/listinfo/nginx" target="_blank">http://nginx.org/mailman/listinfo/nginx</a><br>
> ><br>
<br>
> _______________________________________________<br>
> nginx mailing list<br>
> <a href="mailto:nginx@nginx.org">nginx@nginx.org</a><br>
> <a href="http://nginx.org/mailman/listinfo/nginx" target="_blank">http://nginx.org/mailman/listinfo/nginx</a><br>
<br>
<br>
</div><font color="#888888">--<br>
Igor Sysoev<br>
<a href="http://sysoev.ru/en/" target="_blank">http://sysoev.ru/en/</a><br>
</font><div><div></div><div class="h5"><br>
_______________________________________________<br>
nginx mailing list<br>
<a href="mailto:nginx@nginx.org">nginx@nginx.org</a><br>
<a href="http://nginx.org/mailman/listinfo/nginx" target="_blank">http://nginx.org/mailman/listinfo/nginx</a><br>
</div></div></blockquote></div><br>