nginx 如何配置301重定向

301重定向有两种,一种是不同主域名之间的301重定向,

第二种是同主域名下的301重定向

我这里要说的是第二种——同主域名下的301重定向

把我的规则帖出来给大家看一下,这个测试是成功的

server
{
listen       80;
server_name  www.zouqingshui.net zouqingshui.net ;
index index.html index.htm index.php;
root  /data0/htdocs/www.zouqingshui.net;
if ($host != ‘www.zouqingshui.net’ ) {
rewrite ^/(.*)$ http://www.zouqingshui.net/$1 permanent;
}

include rewrite.conf;

location /status {
stub_status            on;
access_log     on;
}
}

此条目发表在 nginx, 邹清水 分类目录,贴了 , , 标签。将固定链接加入收藏夹。

发表评论

电子邮件地址不会被公开。 必填项已被标记为 *

*

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>