Was wondering if anybody could help. Thanks so much!
Problem:
cool.example.com
redirect to https://www.example.com
Goal:
We're trying to only redirect
http://example.com
http://www.example.com
to https://www.example.com
Current code
Current code in web.config is this. Stuck on <match url="(.*)">
Below is rest of rewrite rule.
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect to https">
<match url="(.*)" />
<conditions>
<add input="{SERVER_PORT}" pattern="443" negate="true" />
</conditions>
<action type="Redirect" url="https://www.example.com" />
</rule>
</rules>
</rewrite>
<modules runAllManagedModulesForAllRequests="true"/>
<defaultDocument enabled="true">
<files>
<clear/>
<!--Remove this line or place below to deprecate-->
<add value="default.aspx"/>
<add value="index.html"/>
<add value="index.php"/>
<add value="default.html"/>
</files>
</defaultDocument>
Modify <match url="(.*)" /> to include only example.com and www.example.com - right now you're matching all urls.
http://learn.iis.net/page.aspx/461/creating-rewrite-rules-for-the-url-rewrite-module/
Try this:
<rule name="Rewrite HTTP to HTTPS" stopProcessing="false" enabled="false">
<match url=".*" />
<conditions>
<add input="{HTTPS}" pattern="off" />
<add input="{HTTP_HOST}" type=”Pattern” pattern="^(www\.)?example.com$">
</conditions>
<action type="Redirect" url="https://www.example.com{REQUEST_URI}" appendQueryString="false" redirectType="Permanent" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With