How would you write an http to https redirect rule for web.config on IIS8 that would go directly to preferred domain with www.?
How would you write an http to https redirect rule for web.config on IIS8 that would go directly to preferred domain with www.? - If a page has internal and external outgoing links to redirecting URLs, it’s returning 3xx (301, 302, etc.) HTTP status codes standing for redirection. This issue means that the page does not exist on a permanent or temporary basis. It appears on most of the popular web browsers, usually caused by a misconfigured website. However, there are some steps you can take to ensure the issue isn’t on your side. You can find more details about redirecting URLs by reading the Google Search Central overview. In this article, we’ll go over how you can fix the How would you write an http to https redirect rule for web.config on IIS8 that would go directly to preferred domain with www.? error on your web browser. Problem :
Solution :
We hope that this article has helped you resolve the web-hosting, redirects, https error in your web browsers. Enjoy browsing the internet uninterrupted!
I have a site that we just setup with SSL and have a redirect rule set up in web.config. We also use the www. as the preferred domain. The problem I have is I want to skip the middle step in the redirect.
What happens now is if you enter http://example.com, it redirects first to https://example.com, then again to https://www.example.com.
How can I setup the config to redirect straight from http://example.com to https://www.example.com?
Here is the rule I am using now in my web.config.
<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="HTTPS" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="https://HTTP_HOST/R:1" />
</rule>
I have found an answer from another question that I tried and it seems to have worked. If there is a better solution, please provide your solution as well.
<rule name="Force WWW and SSL" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny">
<add input="HTTP_HOST" pattern="^[^www]" />
<add input="HTTPS" pattern="off" />
</conditions>
<action type="Redirect" url="https://www.example.com/R:1"
appendQueryString="true" redirectType="Permanent" />
</rule>
Comments
Post a Comment