IIS 重写 - 创建 SEO 友好 URL

IIS Rewrite - Creating SEO Friendly URL

使用 IIS v8 并尝试创建一些 SEO 友好 URL 的

当前URL如下:

http://www.domain.com/equipment/flexible/technical.cfm?id=2&title=applications

正在尝试创建:

http://www.domain.com/equipment/flexible/2/applications

我在 web.config 中添加了以下规则 - 但似乎不起作用。

<rule name="Product Technical Details">
  <match url="^/equipment/flexible/technical.cfm?([0-9]+)/([_0-9a-z-]+)" />
  <action type="Rewrite" url="/equipment/flexible/technical.cfm?id={R:1}&amp;title={R:2}" />
</rule> 

有什么想法吗?

谢谢!

您的传入 URL 格式为:

http://www.domain.com/equipment/flexible/{id}/{title}

所以,你可以这样修改规则:

<rule name="Product Technical Details">
  <match url="^equipment/flexible/technical/([0-9]+)/([_0-9a-z-]+)" />
  <action type="Rewrite" url="equipment/flexible/technical.cfm?id={R:1}&amp;title={R:2}" />
</rule> 

编辑 1:

domain.com/equipment/flex/technical.cfm?id=2&title=request domain.com/equipment/aero/technical.cfm?id=2&title=basics domain.com/equipment/bulk/technical.cfm?id=2&title=general

Would I have to create individual rules for each of the above urls? or is it possible to create a single rule for all off the above ?

您可以像这样更新规则:

<rule name="Product Technical Details">
  <match url="^equipment/(flex|aero|bulk)/technical/([0-9]+)/([_0-9a-z-]+)" />
  <action type="Rewrite" url="equipment/{R:1}/technical.cfm?id={R:2}&amp;title={R:3}" />
</rule>