查看完整版本: nginx 如何设置301域名跳转

幸福在右 2013-1-24 19:06

nginx 如何设置301域名跳转

<div class="context">
                                                        <p>如a.com访问后直接301定向到www.a.com</p>
<p>a.com后加的地址和路径都会直接定向到www.a.com后的地址和路径</p>
<p>如a.com/list/show.php?id=11 设置后定向到www.a.com/list/show.php?id=11</p>
<p>具体设置规则如下:</p><p><br></p>
<p>server</p>
<p>        {</p>
<p>                listen &nbsp; &nbsp; &nbsp; 80;</p>
<p>                server_name www.a.com a.com;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ($host != 'www.a.com' ) { &nbsp;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return &nbsp;301 http://www.a.com$request_uri;</p>
<p>}</p>
<p>}</p>
                                                </div>
页: [1]
查看完整版本: nginx 如何设置301域名跳转