Classic ASP - 如何为产品页面创建 IIS 重写?

Classic ASP - How do I create an IIS rewrite for the product page?

早上好,

我一直在考虑通过使用 IIS 的 URL 重写选项使我的产品和类别 URL 的 SEO 友好,但是我正在努力并需要一些建议。

我正在尝试实现以下内容:

http://www.dibor.co.uk/Product.asp?ProductId=Y054&title=salle-de-bain-dustbin

http://www.dibor.co.uk/prod/Y054-salle-de-bain-dustbin

有人可以帮我创建需要提交到 URL 重写规则的信息吗?

从外观上看,我需要: - 图案 - 重定向 URL

我认为这应该添加到 web.config

<rules>
<clear />
<rule name="Products rewrite" stopProcessing="true">
   <match url="^prod/(.*?)\-(.*)" />
   <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
      <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
      <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
   </conditions>
   <action type="Rewrite" url="/Product.asp?ProductId={R:1}&title={R:2}" />
</rule>
</rules>

您可以通过添加以下内容使规则更加具体:

^prod/(Y[0-9]{3})\-(.*)

但前提是您确定产品 ID 的格式为 Y000

将默认的 404 错误页面更改为 404.asp 并将 url 解析为 return 正确的信息。这里有一个很好的例子IIS URL Rewrite ASP