Nginx 的重定向(301)

例如需要将 http://heiher.info 重定向成 http://www.heiher.info,其规则可以这么写。

server {
      server_name heiher.info www.heiher.info;
      ...
      if ($host != 'www.heiher.info')
      {
            rewrite ^/(.*)$ http://www.heiher.info/$1 permanent;
      }
      ...
}

Over!

One thought on “Nginx 的重定向(301)”

Leave a Reply

Your email address will not be published. Required fields are marked *