Hi please help me in fixing redirect issue of my website.
I want redirect my domain.com, www.domain.com to https:// www. domain.com.
presently i have the following code to redirect.
<rule name="CanonicalHostNameRule1" stopProcessing="true">
<match url="^(\w*/)?index\.php" />
<conditions>
<add input="{HTTP_HOST}" pattern="domain\.com$" />
</conditions>
<action type="Redirect" url="https://www. domain.com/{R:1}" />
</rule>
<rule name="CanonicalHostNameRule2" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^domain\.com$" />
</conditions>
<action type="Redirect" url="https://www. domain.com/{R:1}" />
</rule>
now, my domain.com is redirecting to https:// www. domain.com but, www . domain.com is not redirect to https version. I have tried few codes from search but i have getting redirect loop errors.Please share your suggestion to fix this issue.
This rule below will take care of http to https for both www and non www request and the final url will be same for all the request https://www.domain.com
Copy of the web config:
<rewrite>
<rewriteMaps>
<rewriteMap name="root">
<add key="/root/" value="/" />
</rewriteMap>
</rewriteMaps>
<rules>
<rule name="To HTTPS" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://www.domain.com/{R:1}" redirectType="SeeOther" />
</rule>
</rules>
</rewrite>
You can do this by GUI and URL rewrite module:
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.