Hi Juan,<br><br>Try using two server directives -- one for http and one for https.&nbsp; The server directive chosen depends on the port that is requested.&nbsp; Something like this:<br><br>server {<br>&nbsp;&nbsp;&nbsp; listen&nbsp; 80;&nbsp; # http<br>&nbsp;&nbsp;&nbsp; server_name&nbsp; <a href="http://www.yoursite.com">www.yoursite.com</a>;<br>
&nbsp;&nbsp;&nbsp; [...]<br>&nbsp;&nbsp;&nbsp; location /robots.txt {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;<br>&nbsp;&nbsp;&nbsp; }<br>}<br>server {<br>&nbsp;&nbsp;&nbsp; listen&nbsp; 443;&nbsp; # https<br>&nbsp;&nbsp;&nbsp; server_name&nbsp; <a href="http://www.yoursite.com">www.yoursite.com</a>;<br>&nbsp;&nbsp;&nbsp; [...]<br>&nbsp;&nbsp;&nbsp; location /robots.txt {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rewrite (.*)&nbsp; /robots_ssl.txt;<br>&nbsp;&nbsp;&nbsp; }<br>}<br><br><br><div class="gmail_quote">On Wed, Jan 7, 2009 at 9:06 AM, Juan Fco. Giordana <span dir="ltr">&lt;<a href="mailto:juangiordana@gmail.com">juangiordana@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hello list,<br>
<br>
I&#39;m using nginx-0.6.34 with the try_files patch applied and I&#39;m trying to serve an alternate robots.txt for requests on port 443 so pages under secure connections are not shown by web crawlers.<br>
<br>
I&#39;ve tried many different approaches and couldn&#39;t get any of them to work as I expected:<br>
<br>
&nbsp;if ($server_port = 443)<br>
&nbsp;if ($remote_port = 443)<br>
&nbsp;if ($scheme = https)<br>
&nbsp;With and without the location block.<br>
&nbsp;if () blocks inside @try_files rule.<br>
&nbsp;redirect flags: break, last, pemanent.<br>
&nbsp;All rewrite rules disabled except the one in question.<br>
<br>
server {<br>
 &nbsp; &nbsp;[...]<br>
 &nbsp; &nbsp;location /robots.txt {<br>
 &nbsp; &nbsp; &nbsp; &nbsp;if ($server_port = 443) {<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;rewrite ^robots\.txt$ robots_ssl.txt last;<br>
 &nbsp; &nbsp; &nbsp; &nbsp;}<br>
 &nbsp; &nbsp;}<br>
 &nbsp; &nbsp;[...]<br>
}<br>
<br>
Most of these approaches returned always robots.txt on both SSL and NON-SSL while others 404 error under SSL. None robots_ssl.txt.<br>
<br>
Am I doing something wrong?<br>
<br>
Thanks!<br>
<br>
</blockquote></div><br>