简体   繁体   中英

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. 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. 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}"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM