【发布时间】:2017-01-28 02:39:09
【问题描述】:
我们有一个 IIS 8.5 设置,其中单个网站绑定到 domain.com 并包含许多 IIS 应用程序,这些应用程序以 domain.com/app1、domain.com/app2 等方式访问。
这些应用程序中的每一个都指向相同的物理路径,因此它们都共享一个 web.config。这是特定的 CMS 配置。
我已将通常的 URL 重写规则(重定向到 HTTPS、强制小写、添加斜杠等)应用于每个应用程序共享的 web.config,但我意识到这些规则仅适用于应用程序名称之后的 URL。我拥有的规则只是使用 URL 重写 GUI 添加的标准规则:
<rewrite>
<rules>
<rule name="Enforce lowercase" stopProcessing="true">
<match url="[A-Z]" ignoreCase="false" />
<action type="Redirect" url="{ToLower:{URL}}" redirectType="Permanent" />
</rule>
<rule name="Add trailing slash" stopProcessing="true">
<match url="(.*[^/])$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
</conditions>
<action type="Redirect" url="{R:1}/" redirectType="Permanent" />
</rule>
<rule name="Redirect to HTTPS" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
因此,例如,http://domain.com/APP1/PATH 重定向到 https://domain.com/APP1/path/。此外,https://domain.com/app1不会重定向到https://domain.com/app1/。
HTTPS 规则很好,但谁能告诉我如何配置其他 2 条规则,以便它们与整个 URL 一起使用,请记住,特定的应用程序名称(app1、app2 等)需要通用处理.
更新
我发现我可以使用 IIS 中的全局规则(在服务器级别)强制使用小写 URL,这足以满足我的需要。但似乎无法复制用于添加/删除尾部斜杠的网站级规则。
【问题讨论】:
标签: iis seo url-rewrite-module