Regex 301重定向正则表达式

Regex 301重定向正则表达式,regex,wordpress,url,redirect,Regex,Wordpress,Url,Redirect,我正在尝试重定向301页。我遇到了一个问题,我陷入其中。 第1页: 对于上面的页面,我将重定向正则表达式编写为: Source URL: /the-magazine/2012-springsummer-issue/([A-Za-z].*) Target URL: https://www.example.com/article/$1 $1替换(.*)捕获的所有文本 我还有一页: 2nd Page: https://test.example.com/category/the-magazine/20

我正在尝试重定向301页。我遇到了一个问题,我陷入其中。 第1页:

对于上面的页面,我将重定向正则表达式编写为:

Source URL: /the-magazine/2012-springsummer-issue/([A-Za-z].*)
Target URL: https://www.example.com/article/$1
$1替换(.*)捕获的所有文本

我还有一页:

2nd Page: https://test.example.com/category/the-magazine/2012-springsummer-issue
此页面也正在重定向。 如何编写正则表达式来说明“/category/”是否存在不要重定向到目标URL:

提前谢谢你这是你想要的吗

表达式:

  • 确保没有具有负回溯的
    \category
  • 逐字匹配:
    \/杂志\/2012春夏版\/
  • 捕获url的其余部分:
    ([A-Za-z].*)

例1:

https://test.example.com/the-magazine/2012-springsummer-issue/about-last-night-event-planning
匹配
/the magazine/2012春夏版/about last night event planning
,捕获
about last night event planning

例2:

https://test.example.com/category/the-magazine/2012-springsummer-issue/about-last-night-event-planning

不匹配,不捕获

是的。非常感谢。这是否回答了您的问题?