Redirect IIS http到https重定向规则适用于浏览器,但因API调用而中断(返回401)
我希望访问我的安全站点(使用Windows身份验证设置)的用户始终使用Redirect IIS http到https重定向规则适用于浏览器,但因API调用而中断(返回401),redirect,iis,url-rewriting,http-redirect,http-status-code-401,Redirect,Iis,Url Rewriting,Http Redirect,Http Status Code 401,我希望访问我的安全站点(使用Windows身份验证设置)的用户始终使用https。但是知道他们中的许多人无意中将httpurl添加到书签后,我决定打开http,而使用http重定向https 因此,我安装并设置了此规则: <rule name="HTTP/S to HTTPS Redirect" enabled="true" stopProcessing="true"> <match url="(.*)" /> &
https
。但是知道他们中的许多人无意中将http
url添加到书签后,我决定打开http
,而使用http
重定向https
因此,我安装并设置了此规则:
<rule name="HTTP/S to HTTPS Redirect" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny">
<add input="{SERVER_PORT_SECURE}" pattern="^0$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" appendQueryString="false" />
</rule>
我已经验证了凭据是否正确,并且我已经验证了他们何时将脚本更改为使用https
一切正常。此外,如果他们将脚本保留为http
,并且我禁用了http
到https
重定向,那么他们的脚本工作正常
那么,如何配置我的服务器以正确地将这些api调用从http
重定向到https
,而不会导致错误
或者这是脚本的一个问题?似乎是相同的问题,但对于apache:。我正在使用IIS,我不知道如何使用URL重写为IIS重新创建解决方案。您甚至不知道您使用的是哪种401,所以请停止猜测。在这种情况下,通常使用失败的请求跟踪。运行它,看看你发现了什么。
401 - Unauthorized: Access is denied due to invalid credentials.
Server Error
401 - Unauthorized: Access is denied due to invalid credentials.
You do not have permission to view this directory or page using the credentials that you supplied.