将URL转换为正则表达式

时间:2012-02-19 18:20:28

标签: c# asp.net regex

我在asp.net中使用Intelligencia.UrlRewriter.dll进行网址重写,但我不知道正则表达式。是否有人可以帮助我将这些网址转换为正则表达式。

http://localhost:50788/catalog.aspx?VendorID=1&CategoryID=1

可以更改VendorID以及CategoryID。

http://localhost:50788/Product.aspx?ProductID=1

同样可以更改ProductID。 我实际上想在web.confg文件中为这些查询字符串编写正则表达式,例如

<!-- Rewrite department pages -->
    <rewrite url="/Index" to="~/Default.aspx" />

还有一件事,除此之外还有其他最好的网址重写器吗?

1 个答案:

答案 0 :(得分:1)

您的问题非常不清楚,正如其他人所指出的那样。这是你想要做的吗?

new Regex(@"http://localhost:50788/catalog\.aspx\?VendorID=\d+&CategoryID=\d+");

new Regex(@"http://localhost:50788/Product\.aspx\?ProductID=\d+");
相关问题