Hello,
Can someone please help me in 301 redirecting:
from HTTP to HTTPS and, from non-www to www
<rule name="Redirect to www" stopProcessing="false"> <match url=".*" /> <conditions> <add input="{HTTP_CLUSTER_HTTPS}" pattern="^domain.com$" /> </conditions> <action type="Redirect" url="http://www.domain.com/{R:0}" redirectType="Permanent" /></rule><rule name="Redirect to HTTPS"> <match url=".*"/> <conditions> <add input="{HTTP_CLUSTER_HTTPS}" pattern="^on$" negate="true"/> <add input="{HTTP_CLUSTER_HTTPS}" pattern=".+" negate="true"/> </conditions> <action type="Redirect" url="https://www.domain.com/{R:1}" appendQueryString="true" redirectType="Permanent"/></rule>
Above only loads site if it is https://www.domain.com, or else it gets 500 error.
500 - Internal server error.
There is a problem with the resource you are looking for, and it cannot be displayed.
--------------Update--------------
For the following code:
<rules><rule name="Redirect to HTTPS" stopProcessing="true"><match url=".*"/><conditions><add input="{HTTP_CLUSTER_HTTPS}" pattern="^on$" negate="true"/><add input="{HTTP_CLUSTER_HTTPS}" pattern=".+" negate="true"/></conditions><action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent"/></rule></rules>
I have the follow result:
https://www.domain.com/ -> https://www.domain.com/
http://www.domain.com/ -> https://www.domain.com/
https://domain.com/ -> https://domain.com/
http://domain.com/ -> https://domain.com/