【发布时间】:2013-04-01 18:29:25
【问题描述】:
我正在尝试创建以下 URL 重写。
<rule name="Imported Rule 3">
<match url="^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)" ignoreCase="true" />
<action type="Rewrite" url="/{R:0}/{R:1}.aspx?p={R:2}&title={R:3}" appendQueryString="true" />
</rule>
我希望以下网址重写为以下内容。
/Catalog/Product/1/Title-Description
到
/Catalog/Product.aspx?pid=1&title=Title-Description
和
/Events/Detail/1/Today
/Events/Detail.aspx?pid=1&title=Title-Description
基本上,我希望写作具有通用性并适用于多种场景。 每当有一个带有 4 个斜杠的 url 时,我希望重写规则将其拾取并将其转换为 url。
所以事件的url为
1/1/1/1 将是有效的。
这将转换为
/1/1.aspx?pid=1&title=1
只是给你一个例子。
我不想为每个场景编写单独的重写。
但是,我编写的上述重写一直在服务器上引发错误,我似乎无法找出我的语法有什么问题。服务器出现了一个通用的 500 错误,所以我无法缩小范围。
我很确定问题出在操作标签上,
我写成
<action type="Rewrite" url="/{R:0}/{R:1}.aspx?p={R:2}&title={R:3}" appendQueryString="true" />
和
<action type="Rewrite" url="/{R:1}/{R:2}.aspx?p={R:3}&title={R:4}" appendQueryString="true" />
这两个选项都不起作用。
【问题讨论】:
标签: asp.net url-rewriting seo web-config url-rewrite-module