我有以下匹配表达式:
((?:[a-z0-9\-]*\.){1,}[a-z0-9\-]*)/training/([A-Za-z0-9]+)/$它适用于:
http://training.dev.local/training/xxxxxxx/但是,当重写规则应用于web配置时,它对于C# web应用程序是无法识别的。
<rule name="Train redirect" stopProcessing="true">
<match url="((?:[a-z0-9\-]*\.){1,}[a-z0-9\-]*)/training/([A-Za-z0-9]+)/$" ignoreCase="true" />
<action type="Rewrite" url="train-redirect/?code={R:2}" />
</rule>我正在使用regex101测试:https://regex101.com/r/sL2nA6/3
发布于 2015-09-16 11:31:31
查看Creating Rewrite Rules for the URL Rewrite Module 教程,可以看到只有URL中的路径与正则表达式匹配。因此,您的正则表达式可以写成:
^training/([A-Za-z0-9]+)/$(上面的正则表达式不需要忽略大小写规则)
并且重写操作应相应地更改为:
<action type="Rewrite" url="train-redirect/?code={R:1}" />https://stackoverflow.com/questions/32586724
复制相似问题