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">&lt;<a href="mailto:igor@sysoev.ru">igor@sysoev.ru</a>&gt;</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>
&gt; Thank you, I actually resolved it by:<br>
&gt;<br>
&gt; location / {<br>
&gt;   allow 1.1.1.1;<br>
&gt;   deny all;<br>
&gt;   error_page 403 = @redirect_towww;<br>
&gt; }<br>
&gt;<br>
&gt; location @redirect_towww<br>
&gt; {<br>
&gt;   rewrite ^(.*) <a href="http://www.primarydomain.com" target="_blank">http://www.primarydomain.com</a>$1 permanent;<br>
&gt; }<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>
&gt; On Sun, Oct 17, 2010 at 11:28 AM, helen &lt;<a href="mailto:nginx-forum@nginx.us">nginx-forum@nginx.us</a>&gt; wrote:<br>
&gt;<br>
&gt; &gt; On Sun, 17 Oct 2010 10:36:42 -0400, Ilan Berkner  wrote:<br>
&gt; &gt;<br>
&gt; &gt; [...]<br>
&gt; &gt; &gt; The above code works as expected, but I would like to do something<br>
&gt; &gt; like<br>
&gt; &gt; &gt; this:<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; location / {<br>
&gt; &gt; &gt;   if not 1.1.1.1 or 1.1.1.2 or 1.1.1.3 do a 301 redirect to<br>
&gt; &gt; &gt; <a href="http://www.domain.com" target="_blank">www.domain.com</a>(with request uri)<br>
&gt; &gt; &gt; }<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; is this possible?<br>
&gt; &gt;<br>
&gt; &gt; Use the nginx geo module  to set up a boolean-style variable - say,<br>
&gt; &gt; $internal_ip.  Then put something like this in the server block for your<br>
&gt; &gt; test site:<br>
&gt; &gt;<br>
&gt; &gt; if ($internal_ip != 1) {<br>
&gt; &gt;        rewrite ^ <a href="http://your.public.site/" target="_blank">http://your.public.site/</a> permanent;<br>
&gt; &gt; }<br>
&gt; &gt;<br>
&gt; &gt; helen<br>
&gt; &gt;<br>
&gt; &gt; Posted at Nginx Forum:<br>
&gt; &gt; <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>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; _______________________________________________<br>
&gt; &gt; nginx mailing list<br>
&gt; &gt; <a href="mailto:nginx@nginx.org">nginx@nginx.org</a><br>
&gt; &gt; <a href="http://nginx.org/mailman/listinfo/nginx" target="_blank">http://nginx.org/mailman/listinfo/nginx</a><br>
&gt; &gt;<br>
<br>
&gt; _______________________________________________<br>
&gt; nginx mailing list<br>
&gt; <a href="mailto:nginx@nginx.org">nginx@nginx.org</a><br>
&gt; <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>