我们如何将这两个重定向URL合并(一般化)为一个。
例如:
URL1:(?i)/MathBlog/10-common-math-errors-made-by-elementary-students/
=> /mathblog/common-math-errors-made-by-elementary-students/
网址2:(?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
可用,然后附加到重定向网址或忽略它。
答案 0 :(得分:0)
这个怎么样:
(?i)(\/MathBlog(?:\/amp)?\/)10-(common-math-errors-made-by-elementary-students\/)
=> $1$2