redirect from http to https://www.RSS

4 replies

Last post May 04, 2020 03:54 AM by Yuk Ding

  • redirect from http to https://www.

    May 02, 2020 02:58 PM|anuj9122|LINK

    Hello

    I want to redirect http://projectok.com , http://www.projectok.com , https://projectok.com to https://www.projectok.com .

    this is my conf file

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
    <system.webServer>
    <rewrite>
    <rules>
    <rule name="http to https" stopProcessing="true">
    <match url="(.*)" />
    <conditions>
    <add input="{HTTPS}" pattern="^OFF$" />
    </conditions>
    <action type="Redirect" url="https://www.{HTTP_HOST}/{R:1}" redirectType="SeeOther" />
    </rule>
    </rules>
    </rewrite>
    </system.webServer>
    </configuration>

    In this .conf file everything working except this one http://www.projectok.com .

    When i open http://www.projectok.com it redirect to https://www.www.projectok.com/

    Please guide?

  • Re: redirect from http to https://www.

    May 02, 2020 06:59 PM|lextm|LINK

    Add a condition to check if HTTP_HOST already contains www.

    Lex Li
    Affordable IIS Consulting Services at https://support.lextudio.com/services/consulting.html
    ---------------------------
    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: redirect from http to https://www.

    May 02, 2020 07:05 PM|anuj9122|LINK

    How to add condition?

  • Re: redirect from http to https://www.

    May 02, 2020 08:14 PM|lextm|LINK

    Your rule already uses a condition, so how did you add it? Ask Google if you really don't know how to.

    Lex Li
    Affordable IIS Consulting Services at https://support.lextudio.com/services/consulting.html
    ---------------------------
    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: redirect from http to https://www.

    May 04, 2020 03:54 AM|Yuk Ding|LINK

    Hi anuj9122,

    I think you need  two rule to achieve this. one for http to https and another one for https non-www to https www.

    <rule name="http to https" stopProcessing="true">
    <match url="(.*)" />
    <conditions>
                            <add input="{HTTPS}" pattern="^OFF$" />
                            <add input="{HTTP_HOST}" pattern="^(www\.)?projectok.com" />
    </conditions>
    <action type="Redirect" url="https://www.projectok.com/{R:1}" redirectType="Temporary" />
    </rule>
                    <rule name="non-www to www" stopProcessing="true">
                        <match url="(.*)" />
                        <conditions>
                            <add input="{HTTP_HOST}" pattern="projectok.com" />
                            <add input="{HTTPS}" pattern="^on$" />
                        </conditions>
                        <action type="Redirect" url="https://www.projectok.com/{R:1}" />
                    </rule>

    Best Regards,

    Jokies Ding

    Yuk Ding

    MSDN Community Support
    Please remember to "Mark as Answer" the responses that resolved your issue.