【发布时间】:2019-10-05 21:33:18
【问题描述】:
上周我在 iis 中添加了 ssl,并在我的网站的 web.config 中配置了重定向 301 规则。
今天我注意到https://www 版本没有重定向到我网站的https://non-www 版本,并且图片和css 文件等资源在我的网站的两个版本中都可用。
我添加到 web.config 中的这些规则是否正确?
由于 IIS 和 wordpress,我不得不将资源重定向和 Unicode Url 添加到 web.config。
从 http 到 https 的重定向工作正常
从 http//www 重定向到 http://non-www 正在工作
但是从 https//www 重定向到 https://non-www 不起作用!
我的 web.config 文件:
<rewrite>
<rules>
<rule name="HTTPS" patternSyntax="ECMAScript" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}"
redirectType="Permanent" />
</rule>
<rule name="Redirect Image to HTTP" stopProcessing="true">
<match url=".*\.(gif|jpg|jpeg|png|css|js|pdf|ttf|woff2|woff|mp4)$"
ignoreCase="true" />
<action type="Rewrite" url="{R:0}" />
</rule>
<rule name="WordPress Rule" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="index.php" />
<serverVariables>
<set name="REQUEST_URI" value="{UNENCODED_URL}" replace="true" />
</serverVariables>
</rule>
</rules>
【问题讨论】:
标签: iis https url-redirection