如何使用正则表达式将一个站点的所有页面重定向到另一个站点(使用重定向WP插件)?

时间:2018-04-22 18:49:08

标签: regex wordpress redirect url-redirection

我需要将site / old-domain /的所有页面重定向到/ new-domain /,并且很难使用Wordpress的重定向插件找出简单的正则表达式。谷歌搜索没有帮助,或者我遗漏了一些基本的东西。

例如,我想重定向 / old-domain / photos / cats TO:/ new-domain / photos / cats

和/ old-domain / products / shoes TO:/ new-domain / products / shoes

我虽然应该输入: old-domain /(.*)>新域/ $ 1

但这没有效果。

提前感谢您的帮助。

2 个答案:

答案 0 :(得分:0)

基于https://redirection.me/上的示例,看起来您需要在开始时使用斜杠才能正确匹配。

尝试:

/old-domain/(.*) .... /new-domain/($1)

答案 1 :(得分:0)

感谢大家的帮助。你对语法完全正确。此外,您无法将原始域放入源框中。

以下是其他人发现此问题的答案和语法(我在谷歌搜索时非常困难)

将olddomain.com重定向到newdomain.com:

/(.*)
http://newdomain.com/$1/
<make sure the regex button is checked>