我们如何将这两个重定向URL合并(使其泛化)为一个。
例如:
URL1:(?i)/MathBlog/10-common-math-errors-made-by-elementary-students/ => /mathblog/common-math-errors-made-by-elementary-students/
URL2:(?i)/MathBlog/amp/10-common-math-errors-made-by-elementary-students/ => /mathblog/amp/common-math-errors-made-by-elementary-students/
应该成为URL3:(?i)/MathBlog/{regex}/10-common-math-errors-made-by-elementary-students/ => /mathblog/{/amp}/common-math-errors-made-by-elementary-students/
{/amp}必须是可选的,例如,如果/amp可用,则追加到重定向url或直接忽略它。
发布于 2017-06-15 23:20:31
这样如何:
(?i)(\/MathBlog(?:\/amp)?\/)10-(common-math-errors-made-by-elementary-students\/) => $1$2
https://stackoverflow.com/questions/44569692
复制相似问题