nginx的301重定向代码

作者:monface 发布时间:March 9, 2010 分类:计算机,Google No Comments

还是由于天朝的原因,Google的企业邮局的ghs一直被伟大GFW封印,而且ghs的ip恐怕都被封得差不多了,所以现在我们就利用nginx实现301转向.
首先Google邮局的申请及MX记录设置这里就不说明了.将mail的a记录指向空间的ip.然后再nginx.conf里面创建如下代码

server
        {
                listen       80;
                server_name mail.totnt.com;
                rewrite ^(.*) http://mail.google.com/a/totnt.com$1 permanent;
        }

其中http://mail.google.com/a/totnt.com 就是你所要转向的位置,如果你的域名是menface.net,就修改为http://mail.google.com/a/menface.net.修改完成当然检查一下nginx配置文件的正确性
/usr/local/nginx/sbin/nginx -t
出现一下信息表示成功
  the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
  the configuration file /usr/local/nginx/conf/nginx.conf was tested successfully

再来一下
kill -HUP `cat /usr/local/nginx/logs/nginx.pid`
这样,你的域名http://mail.totnt.com就可以访问了

标签: google, mail, nginx, 301

添加新评论 »