【问题标题】:Classic ASP - How do I create an IIS rewrite for the product page? [duplicate]经典 ASP - 如何为产品页面创建 IIS 重写? [复制]
【发布时间】:2015-10-20 03:45:23
【问题描述】:

早安,

我一直在考虑通过使用 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 重写规则中的信息吗?

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

【问题讨论】:

  • 改写成http://www.dibor.co.uk/prod/Y054/salle-de-bain-dustbin会更方便

标签: url-rewriting asp-classic iis-7 iis-7.5 url-rewrite-module


【解决方案1】:

我认为这应该添加到 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

【讨论】:

    【解决方案2】:

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

    【讨论】:

    • 总是在你的答案中添加重要的链接内容。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-08-20
    • 1970-01-01
    • 1970-01-01
    • 2023-03-17
    • 2013-09-01
    • 2023-03-09
    • 2010-12-07
    相关资源
    最近更新 更多