[英]How to past together redirect 301 rewrite iis-8.5?
i faced a problem. 我遇到了一个问题。 There is a main domaim https://example.com i have a redirect from http to https. 有一个主要的域名https://example.com,我从http重定向到https。 everything works, but there is a problem, when i try to print in the url adress request line www.example.com/exam/exam i am redirected to the maim page and in the adress request line i see the following adress : https//example.com and other requests are deleted.But if I enter into the address bar https://example.com/exam/exam - then everything works. 一切正常,但是有一个问题,当我尝试在url地址请求行www.example.com/exam/exam中打印时,我被重定向到maim页面,而在地址请求行中,我看到以下地址:https / /example.com和其他请求将被删除。但是,如果我在地址栏中输入https://example.com/exam/exam ,则一切正常。 I need your help and advise on how can i improve rewrite and what is wrong in my code? 我需要您的帮助并就如何改善重写以及代码中的错误提出建议。
<rule name="Redirect to HTTPS" enabled="false" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" />
<conditions>
<add input="{HTTPS}" pattern="^ON$" />
<add input="{HTTP_HOST}" pattern="^([\d\w\.]+)" />
</conditions>
<action type="Redirect" url="https://{C:1}/{REQUEST_URI}" />
</rule>
<rule name="RedirectDoubleHTTPS" enabled="true" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" />
<conditions>
<add input="{HTTPS}" pattern="off" />
</conditions>
<action type="Redirect" url="https://example.com" />
</rule>
The problem in your second rule. 第二条规则中的问题。 It should be like that: 应该是这样的:
<rule name="RedirectDoubleHTTPS" enabled="true" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" />
<conditions>
<add input="{HTTPS}" pattern="off" />
</conditions>
<action type="Redirect" url="https://example.com{REQUEST_URI}" />
</rule>
Also your first rule have minor fix. 另外,您的第一条规则有较小的修正。 Instead https://{C:1}/{REQUEST_URI}"
should be https://{C:1}{REQUEST_URI}"
而是https://{C:1}/{REQUEST_URI}"
应该是https://{C:1}{REQUEST_URI}"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.