【发布时间】:2017-05-01 14:19:05
【问题描述】:
这是我的 web.config 规则
<rule name="spiderRedirect" stopProcessing="true">
<match url=".post/([0-9a-zA-Z]+)/([0-9a-zA-Z]+)/([0-9a-zA-Z-]+)" />
<action type="Redirect" url="https://example.net/bot/post.php?category={toLower:{R:1}}&id={toLower:{R:2}}&title={toLower:{R:3}}" appendQueryString="false" />
</rule>
这应该给出这个结果
输入:
https://example.net/post/celebrity/4cHYQ7i/maisie-williams
应该导致:
{R1}: celebrity
{R2}: 4cHYQ7i
{R3}: maisie-williams
它应该重定向到:
https://example.net/bot/post.php?category=celebrity&id=4cHYQ7i&title=maisie-williams
这个输入:
https://example.net/post/nerdy/NE5cHQZ/when-i-have-to-do-technical-support
应该导致:
{R1}: nerdy
{R2}: NE5cHQZ
{R3}: when-i-have-to-do-technical-support
服务器运行,我很确定正则表达式是正确的,但从未触发规则。即使我使用上述输入,我也永远不会重定向到谷歌。
为什么没有触发规则?
【问题讨论】:
-
为什么你的正则表达式有一个前导点?
-
另外,您应该在正则表达式中使用
^$锚点以避免错误捕获。
标签: asp.net regex redirect iis web-config