2017-06-15 112 views
0

我們如何將這兩個重定向URL合併(使其泛化)爲一個。重定向通用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}必須是可選的,I,E如果/amp可用,則附加重定向url或者忽略它。

+0

你的意思'/ MathBlog(/ AMP)/ 10-共數學錯誤,作出─ by-elementary-students /'=>'/ mathblog $ 1/common-math-errors-made-by-elementary-students /'? –

回答

0

如何:(我)?

(?i)(\/MathBlog(?:\/amp)?\/)10-(common-math-errors-made-by-elementary-students\/) =>$1$2

Live demo