将 url 子页面从 /blog/site/info 重定向到 /news/site/info 的正则表达式解决方案
Regex solution to redirect url subpages from /blog/site/info to /news/site/info
我目前正在查看来自
的路由页面
http://example.com/博客/article/information
到
http://example.com/新闻/article/information
我正在使用 umbraco cms(301 url 跟踪器)的插件,它需要两个值。
1.Regex
2.Redirect URL,这支持反向引用。
我尝试了这些值,但没有成功
^/blog/1
news/
谢谢,
男
要实际使用反向引用,您需要先在正则表达式模式中声明一个捕获组。捕获组用一对未转义的括号定义:(...)
其中 ...
代表要捕获的模式。
因此,您可以使用
- 正则表达式:
^/blog/(.*)
- 重写:
/news/
其中 ^/blog/(.*)
匹配输入字符串开头的 /blog/
,然后使用 .*
将其后的所有内容捕获到第 1 组(换行符以外的任何 0+ 个字符) , 并替换为 /news/
+ Group 1 中的值。
我目前正在查看来自
的路由页面http://example.com/博客/article/information
到
http://example.com/新闻/article/information
我正在使用 umbraco cms(301 url 跟踪器)的插件,它需要两个值。
1.Regex
2.Redirect URL,这支持反向引用。
我尝试了这些值,但没有成功
^/blog/1
news/
谢谢,
男
要实际使用反向引用,您需要先在正则表达式模式中声明一个捕获组。捕获组用一对未转义的括号定义:(...)
其中 ...
代表要捕获的模式。
因此,您可以使用
- 正则表达式:
^/blog/(.*)
- 重写:
/news/
其中 ^/blog/(.*)
匹配输入字符串开头的 /blog/
,然后使用 .*
将其后的所有内容捕获到第 1 组(换行符以外的任何 0+ 个字符) , 并替换为 /news/
+ Group 1 中的值。