简体   繁体   中英

Regular expression in web.config rewrite not working

I am having a tough time getting the regular expression right.

In the example below, the string is appended with _Schedule to go to the schedule.aspx page with the matching parameter.

I just cant seem to get the regular expression correct, but maybe it is, but I do not have the rewriteMap key correct.

If I use www.MyDomain.com/Friday_December_6_2013_700PM_Schedule, it is going to the schedule.aspx page, but not grabbing the the IDNum parameter.

<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Rewrite for Schedule" stopProcessing="true">
<match url=".*?(_Schedule)" />
<action type="Rewrite" url="schedule.aspx?IDNum={Schedule:{R:1}}" />
</rule>
</rules>
<rewriteMaps>
<rewriteMap name="Schedule">
<add key="Friday_December_6_2013_700PM" value="21" />
</rewriteMap>
</rewriteMaps>
</rewrite>
</system.webServer>
</configuration>

Instead of

.*?(_Schedule)

try this

(.*?)_Schedule

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM