ngin配置301重定向设置方法和nginx子目录301重定向

这篇文章主要介绍了ngin配置301重定向设置方法和nginx子目录301重定向,需要的朋友可以参考下
nginx版本为1.1.19。

若域名由a.com转移到了b.com,并对两个域名有所有权,可以:
复制代码 代码如下:
server{

server_name a.com;
return 301 $scheme://b.com$request_uri;

}

重启服务器,然后看一下成功与否:
复制代码 代码如下:
curl -I a.com

nginx子目录301重定向设置方法友情链接检查

如我想把www.b.com/bfiles/download/转向到dx1.b.com:81/bfiles/download/下,nginx下网站的conf文件里这些写:

复制代码 代码如下:
location ~* ^/bfiles/download/ {
rewrite ^/bfiles/download/(.*)$ http://dx1.b.com:81/bfiles/download/$1 permanent;
}

猜你喜欢

转载自blog.csdn.net/sakura379/article/details/89839887