Search code examples
httphttpsweb-configiis-10

Redirect from HTTP to HTTPS not working, 403 forbidden message in client


I am running Drupal 8.7.7 on IIS 10, with Plesk 17.8.11

From the code in web.config I would expect an automatic reroute from http://www.focusonlineperformance.nl to https://www.focusonlineperformance.nl

But instead, I get a 403 forbidden message on Chrome.

I have tried <match url=".*" /> I have tried <add input="{HTTPS}" pattern="^OFF$" />

I have the following script in web.config:

<rule name="Plesk. SSL redirect for #6" patternSyntax="ECMAScript" 
stopProcessing="true">
                <match url="(.*)" />
                <conditions>
                    <add input="{HTTPS}" pattern="OFF" />
                    <add input="{HTTP_IS_SITEPREVIEW}" pattern="1" 
negate="true" />
 </conditions>
  <serverVariables />
         <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" />
</rule>

Thanks for any help!


Solution

  • Use below URL rewrite rule:

    <configuration>
     <system.webServer>
     <rewrite>
     <rules>
     <rule name="HTTPS force" enabled="true" stopProcessing="true">
     <match url="(.*)" />
     <conditions>
     <add input="{HTTPS}" pattern="off" />
     </conditions>
     <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" />
     </rule>
     </rules>
     </rewrite>
     </system.webServer>
    </configuration>
    

    make sure you configure https binding for the site and with the right certificate.

    and uncheck "Require SSL" by following below steps:

    • Open iis manager. select your site.
    • Double click on SSL setting feature from the middle pane:

    enter image description here

    • Uncheck the require SSL and click on apply.

    enter image description here