在frappe中,我在
hooks.py
中设置重定向,如下所示:
website_redirects = [
...
{ "source": "/login", "target": "/entrar" },
但是,我在设置包含属性的工作重定向时遇到了很多困难。比如从
/login?redirect-to=other-page
到/entrar?redirect-to=other-page
,就是没有传参数。
我终于找到了解决方案,但由于我在网上没有找到任何帮助,并且花了几个小时才找到它,我想我会将其发布在这里,以节省任何面临类似问题的人的时间。
最终的解决方案是将(几乎没有记录的)属性
"match_with_query_string": True
和一些正则表达式结合起来:
website_redirects = [
...
{ "source": r"/login\?(.*)", "target": r"/entrar?\1", "match_with_query_string": True },
{ "source": "/login", "target": "/entrar" },