Web.config中的正则表达式怎么写
使用URLRewriter.dll对URL重定向,在Web.config中要作以下设置
<RewriterConfig>
<Rules>
<RewriterRule>
<LookFor> ~/stock1\.aspx </LookFor>
<SendTo> ~/Module.aspx?p=1 </SendTo>
</RewriterRule>
<RewriterRule>
<LookFor> ~/stock_2\.aspx </LookFor>
<SendTo> ~/Module.aspx?p=2 </SendTo>
</RewriterRule>
<RewriterRule>
<LookFor> ~/stock_3\.aspx </LookFor>
<SendTo> ~/Module.aspx?p=3 </SendTo>
</RewriterRule>
...........
</Rules>
</RewriterConfig>
听说可以换成使用正则表达式来写,但不知怎样写,请教一下大家.
------解决方案-------------------- <LookFor> ~/stock_(\d)\.aspx </LookFor>
------解决方案--------------------楼上正解