I want to redirect https://example.com to https://www.example.com. I have the following rule for redirecting non www http traffic to https://www . . .
<rule name="WWW Redirect1" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^example\.com$" />
</conditions>
<action type="Redirect" url="https://www.example.com/{R:1}" />
</rule>
This will not handle redirecting from https://example.com to https://www.examlple. Right now I currently get the SSL cert error, is it even possible to avoid this?
If you are getting an SSL certificate error, it likely means that either
Your web server is not serving up an SSL certificate for https://www.example.com or;
Your SSL certificate is for example.com not www.example.com. In which case, you'll likely need to address that with your SSL certificate provider.
Not sure that it is an issue with code or config....
Related
I have a domain which has the DNS setting pointing to a VPS.
The VPS has an IIS 10 instance which hosts the simple website using html using bootstrap.
I installed an SSL certificate and added bindings for the https part.
I am able to browse the domain on http and https.
I added the following rule to the web.config:
<system.webServer>
<rewrite>
<rules>
<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>
</rules>
</rewrite>
</system.webServer>
However this does not seem to help. I am still able to browse on http.
I tried the following:
Tried installing URL Rewrite but it looks like Windows Server 2016 and IIS 10 does not allow the installation
Tried enabling Requires SSL option.
This shows the website in http without images but with text
The website is properly displayed in https
What am I missing here?
I was installing the wrong URL rewrite.
This article helped me fix the problem with the right links.
Automatic IIS redirect http to https on Windows Server 2016: https://gridscale.io/en/community/tutorials/iis-redirect-http-to-https-windows/
I want to redirect any www subdomain requests to domain.co.uk, for example
http://www.domain.co.uk
https://www.domain.co.uk
should redirect to
https://domain.co.uk
I have an SSL cert in Azure bound to domain.co.uk
In the Azure portal, in Custom Domains I have set to HTTPS only
In web.config I have the following redirect rule
<rule name="NonWwwRedirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^www.domain\.co.uk$" />
</conditions>
<action type="Redirect" url="https://domain.co.uk/{R:1}" redirectType="Permanent" />
</rule>
Requests to https://www.domain.co.uk give an error saying your connection is not private
Does anyone know why?
Requests to http://www.domain.co.uk redirect to http://domain.co.uk as expected
I have to add a rule for the following and can't get it to work.
The website is available under https www.domain.com. The certificate only works for that. If I try with https domain.com I get an 404 error. How can I redirect from https domain.com to https www.domain.com?
Any ideas?
I already covered when someone uses http und will be redirected to https.
Sorry, I couldn't write the complete url because I have not enough reputation. So I cut out the ://
You Can try This
<rule name="Redirect to HTTPS" stopProcessing="true">
<match url="(.*)" />
<conditions><add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="SeeOther" />
</rule>
We purchased an SSL certificate for one of our domains. The certificate was issued to www.ourdomain.com. I am having great difficulty writing web.config rewrite rules to force both www and https. The problem is the certificate itself. Again, the certificate was issued to the www variant of our domain. As such it is only valid if www is present in the URL. Currently, I am using the following rule:
<rule name="Redirect to WWW" stopProcessing="true" >'
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^www\." negate="true"/>
</conditions>
<action type="Redirect" url="https://www.{HTTP_HOST}{HTTP_URL}" redirectType="Permanent" appendQueryString="false" />
</rule>
<rule name="Redirect to HTTPS">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="OFF"/>
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{HTTP_URL}" redirectType="Permanent" appendQueryString="false" />
</rule>
http ourdomain.com is OK. http www.ourdomain.com is OK. https www.ourdomain.com is OK. https ourdomain.com FAILS with a browser error
I believe it fails because IIS processes SSL before it gets to these rules in the web.config. And because the certificate requires www to be requested, the user browser gets an error. On the error page, you can click "continue anyways" and the web.config rules kick in and force the redirection. Can this be fixed or do I need to buy a new certificate without www in the domain? Other certificates I have installed on the server without www in the domain work for all 4 URL examples.
Update: still looking for feedback
I have a subdomain (subdomain.example.com) that I want to redirect it to this Url format on my website https://example.com/some-web-page.
I created an empty site in IIS, the site only contains a web.config file with this rule:
<rule name="subdomain.example.com Redirect" stopProcessing="false">
<match url="^\/?$" />
<conditions>
<add input="{HTTP_HOST}" pattern=".*subdomain\.example\.com.*" />
</conditions>
<action type="Redirect" redirectType="Found" url="https://example.com/some-web-page/{R:0}" />
</rule>
Now, subdomain.example.com is redirecting as it should but https://subdomain.example.com is taking me to https://example.com home page and the address bar shows an error saying "The identity of the website has not been verified. Server's certificate does not match the Url."
I should also mention that I have purchased an additional certificate for https://subdomain.example.com.
How can I make this https redirect to work in such scenario?