Nginx 尝试使用带有重定向和模式匹配的try_files规则
我不知道如何使用重定向和模式匹配的Nginx 尝试使用带有重定向和模式匹配的try_files规则,nginx,Nginx,我不知道如何使用重定向和模式匹配的try_files 我有两个博客在mysite.com/old_blog和mysite.com/new_blog上。我正在编写nginx规则,将流量从旧的\u博客重定向到新的\u博客。以下规则适用于我: location /old_blog { rewrite ^/old_blog(.*)$ /new_blog$1 permanent; } 我现在正试图重定向一种特定类型的帖子。在旧博客上,URL是/old\u blog/post na
try_files
我有两个博客在mysite.com/old_blog
和mysite.com/new_blog
上。我正在编写nginx规则,将流量从旧的\u博客
重定向到新的\u博客
。以下规则适用于我:
location /old_blog {
rewrite ^/old_blog(.*)$ /new_blog$1 permanent;
}
我现在正试图重定向一种特定类型的帖子。在旧博客上,URL是/old\u blog/post name
(与普通博客相同),但在新博客上,URL是/new\u blog/other/post name
。我想要的是:“从/old\u blog
重定向到/new\u blog
,如果是404,尝试重定向到/new\u blog/other/
,如果仍然没有,那么它就是合法的404”
我试图使用try\u文件
,但未成功:
location /old_blog(.*)$ {
try_files /new_blog$1 /new_blog/other$1 =404;
}
谢谢你的帮助