[英]Parse 404 url and redirect with nginx
I am trying to remove an seo plugin from my forum, and I have MANY 404 pages to deal with. 我正在尝试从论坛中删除seo插件,但我要处理许多404页。
The old url struture is : 旧的url结构是:
http://example.com/board/technical-advice/something-interesting-t2824-15.html http://example.com/board/technical-advice/something-interesting-t2824-15.html
...and the new one is: ...而新的是:
http://example.com/board/viewtopic.php?t=2824 http://example.com/board/viewtopic.php?t=2824
So I would like to parse all 404 urls coming into the /board folder, and redirect them to the new structure. 因此,我想解析进入/ board文件夹的所有404 URL,并将其重定向到新结构。
Is it possible to do this in my Nginx config? 是否可以在我的Nginx配置中执行此操作? If so how? 如果可以,怎么办? Or is there a better place? 还是有更好的地方?
If this is just one format you need to do then you can use below 如果这只是您需要的一种格式,则可以在下面使用
http://example.com/board/technical-advice/something-interesting-t2824-15.html http://example.com/board/viewtopic.php?t=2824 http://example.com/board/technical-advice/something-interesting-t2824-15.html http://example.com/board/viewtopic.php?t=2824
rewrite "^/board/[^/]+/[a-z0-9-]t(\d+).*\.html$" /board/viewtopic.php?t=$1 redirect;
If there are lots of redirects then you should use the approach that @RichardSmith suggested in the comments on below article 如果有很多重定向,则应该使用@RichardSmith在下面的文章评论中建议的方法
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.