【问题标题】:IIS URL Rewrite to not pass the .htm into the rewriteIIS URL 重写不将 .htm 传递给重写
【发布时间】:2015-10-16 04:54:00
【问题描述】:

我有一个带有多个多宿主域的 IIS 服务器。我有 seo 友好 URLS 的基本重写规则。

例子:

www.something.com/here-is-the-page

当前转换为

www.something.com/index.htm?pagetitle=here-is-the-page

问题是一个域需要此规则以允许 URL 以 .htm 结尾。

例子:

www.something.com/here-is-the-page.htm

需要转换成

www.something.com/index.htm?pagetitle=here-is-the-page

(注意,刚刚删除了 .htm,虽然我仍然希望 .htm 显示在位置栏中)...

【问题讨论】:

    标签: iis url-rewriting iis-7.5


    【解决方案1】:

    感谢大家的所有帮助...[讽刺]下面是解决方案。 这里的关键是 MatchAll。

    查看网址

    检查这是否适用于 www.something.com

    检查以确保没有具有 filename.htm 的实际文件

    检查没有同名的目录

    如果文件是 sitemap.htm(确实存在,则不要处理)这应该被之前的文件检查捕获,但只是为了矫枉过正而添加。由于这是重写而不是重定向,因此 .htm 将继续显示在导航栏中。

    <rule name="remove the htm" stopProcessing="true">
      <match url="([_0-9a-z-]+)\.htm$" />
      <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
        <add input="{HTTP_HOST}" pattern="^(www.something.com)$" />
        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
        <add input="{REQUEST_FILENAME}" pattern="sitemap\.htm$" negate="true" />
      </conditions>
      <action type="Rewrite" url="/index.cfm?pagetitle={R:1}" />
    </rule>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-06-27
      • 2013-06-16
      • 1970-01-01
      相关资源
      最近更新 更多