我目前有一个nginx实例,它仅用于保留旧网址的流量。
server {
listen xxx.xxx.IP.IP;
server_name blog.store.com;
if ($http_host = "xxx.xxx.IP.IP"){return 301 $scheme://store.com;}
if ($http_host = blog.store.com){return 301 $scheme://store.com/blog;}
}
这很好但我想添加一条规则,允许人们导航到这个的子目录并保留他们命中的其余路径。
示例:现在,如果有人点击“blog.store.com/page”链接,他们会被带到'store.com/blog'
我希望他们能够点击'blog.store.com/page'并转到'store.com/blog/page'
我尝试了一些
的例子但是1美元和1美元的不同变体不起作用。我错过了什么吗?
提前谢谢
答案 0 :(得分:1)
试试这个:
server {
listen xxx.xxx.IP.IP default_server;
return 301 $scheme://store.com;
}
server {
listen xxx.xxx.IP.IP;
server_name blog.store.com;
return 301 $scheme://store.com/blog$request_uri;
}
答案 1 :(得分:1)
理查德非常感谢你,这是我的新代码。
git reset --hard <commit>
再次感谢!