我想将 /a1LMNFZgg1Y/+/user/update 重写为 a1LMNFZgg1Y/+/user/update
目的就是想去掉前面的斜杠,请问以下的代码如何写?
以下是错误格式,有没有大神能帮忙给出一个正确的参数?
rewrite = [
{
action: “all”
source_topic: “/a1LMNFZgg1Y/+/user/update”
dest_topic: “a1LMNFZgg1Y/+/user/update”
re: “^/a1LMNFZgg1Y/.*”
}
]
这个错是提示你不要在dest_topic 中用通配符 +
目标表达式可以使用
$N
格式的变量来匹配从正则表达式中提取的元素。$N
的值是指从正则表达式中提取的第 N 个元素,例如,$1
是正则表达式提取的第一个元素。同时,表达式中也可以使用
${clientid}
代表客户端Id
, 使用${username}
代表客户端用户名
。
rewrite = [
{
action = "all"
source_topic = "/a1LMNFZgg1Y/+/user/update"
dest_topic = "a1LMNFZgg1Y/$1/user/update"
re = "^/a1LMNFZgg1Y/(.+)/user/update$"
}
]
好的,谢谢,我改为以下方式也能用,但不知会不会有其他问题
rewrite = [
{
action: “all”
source_topic: “/a1LMNFZgg1Y/+/user/update”
dest_topic: “$1”
re: “^/(a1LMNFZgg1Y/(.+)/user/update)$”
}
]