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

 更新时间:2016年1月27日 20:15  点击:1540

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; 

[!--infotagslink--]

相关文章