【发布时间】:2019-05-16 21:44:51
【问题描述】:
我有一个按预期工作的 http 到 https 重定向规则。但是,当我启用 http 到 https 规则时,我无法获得单独的页面重定向规则。我在处理 web.config 和站点配置方面的经验有限,因此无法确定问题所在。
我尝试禁用 http 到 https 规则,然后“旧页面重定向”规则按预期工作。但我需要启用这两个规则。我在此处包含了重写规则以及来自重写映射的示例。请注意,我还为我的 CMS 制定了一些规则来创建 SEF URL。
<rewrite>
<rewriteMaps configSource="Web.RewriteMaps.config" />
<rules>
<rule name="Old Page Redirects" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{OldPages:{REQUEST_URI}}" pattern="(.+)" />
</conditions>
<action type="Redirect" url="{C:1}" appendQueryString="false" redirectType="Permanent" />
</rule>
<rule name="CMS Rule 1" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions logicalGrouping="MatchAny">
<add input="{QUERY_STRING}" pattern="base64_encode[^(]*\([^)]*\)" ignoreCase="false" />
<add input="{QUERY_STRING}" pattern="(>|%3C)([^s]*s)+cript.*(<|%3E)" />
<add input="{QUERY_STRING}" pattern="GLOBALS(=|\[|\%[0-9A-Z]{0,2})" ignoreCase="false" />
<add input="{QUERY_STRING}" pattern="_REQUEST(=|\[|\%[0-9A-Z]{0,2})" ignoreCase="false" />
</conditions>
<action type="CustomResponse" url="index.php" statusCode="403" statusReason="Forbidden" statusDescription="Forbidden" />
</rule>
<rule name="CMS Rule 2">
<match url="(.*)" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{URL}" pattern="^/index.php" ignoreCase="true" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="index.php" />
</rule>
<rule name="HTTP to HTTPS" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" />
</rule>
</rules>
</rewrite>
<!-- sample key and value from rewrite map is below -->
<rewriteMaps>
<rewriteMap name="OldPages">
<add key="/closeup.asp?pid=2115" value="/furniture/cabinets-chests/rosewood-dragon-phoenix-design-armoire-b0hc02xc" />
</rewriteMap>
</rewriteMaps>
【问题讨论】:
标签: web-config url-redirection iis-8