So, we are running on IIS 10.0 and have multiple domains registered at our ISP which all point to the public IP of our webserver. The webserver has only one certificate assigned to a wildcard subdomain. So #.rootdomain.nl
I've setup a URL rewrite to rewrite all the different domains to our root domain: https://www.rootdomain.nl however the problem I'm experiencing is that the first redirect goes alright but the second doesn't gets redirect instead the browser says there no valid certificate for this domain.
URL config:
<rule name="Redirects to www.domain.com" enabled="true" patternSyntax="ECMAScript" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTP_HOST}" pattern="^(www.)?rootdomain.(com|be|de)$" />
</conditions>
<action type="Redirect" url="https://www.rootdomain.nl/{R:0}" redirectType="Permanent" />
</rule>
What I try to achieve:
.com to .nl
www.rootdomain.com -->> redirect -->> www.rootdomain.nl
rootdomain.com -->> redirect -->> www.rootdomain.nl
.de to .nl
www.rootdomain.de-->> redirect -->> www.rootdomain.nl
rootdomain.de-->> redirect -->> www.rootdomain.nl
.be to .nl
www.rootdomain.be-->> redirect -->> www.rootdomain.nl
rootdomain.be-->> redirect -->> www.rootdomain.nl
Offcourse all http trafic must be redirect to HTTPS so that's the second rule:
<rule name="Redirect to HTTPS" enabled="false" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" />
<conditions logicalGrouping="MatchAny" trackAllCaptures="false">
<add input="{HTTPS}" pattern="OFF" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" appendQueryString="false" />
And this is what I experience:
www.rootdomain.com -->> Invalid certificate(Click go anyway) -->> redirect -->> https://www.rootdomain.nl
rootdomain.com -->> Invalid certificate(Click go anyway) -->> redirect -->> https://www.rootdomain.nl
We have to ensure that the HTTPS site binding has the valid certificate configured. Every domain name that the server owns corresponds to the subject of the certificate, otherwise, the browser will prompt an error pertaining to an invalid certificate when we access the browser.
In order to bind multiple certificates to the same port for every domain name, we need to tick the below option.
The result.
At last, we can apply URL rules as we like.
<system.webServer>
<rewrite>
<rules>
<rule name="MyRule" enabled="true" stopProcessing="true">
<match url="(.*)" ignoreCase="false" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{http_host}" pattern="www.bing2.com" />
</conditions>
<action type="Redirect" url="https://www.bing.com" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
</system.webServer>
Feel free to let me know if there is anything I can help with.
Related
how to create rule for IIS redirection www1 domain to www.
example www1.xyz.com -> www.xyz.com
If you want to redirect from www1 to www, you can refer to this link:
<rule name="redirect to www" enabled="false" stopProcessing="true">
<match url="^(.*)$" />
<conditions>
<add input="{HTTP_HOST}" pattern="www1.example.com" />
</conditions>
<action type="Redirect" url="http://www.example.com/{R:1}" />
</rule>
My boss wants to ensure that our internet-challenged users will be able to reach a particular subdomain (https://subdomain.domain.com) by typing it into their browser's address bar as:
https://www.subdomain.domain.com
It seems I am able to do the HTTP -> HTTPS redirect without issue using IIS's Rewrite module. Also it seems I am able to do the WWW.subdomain.domain.com to subdomain.domain.com with the rewrite module. However, combining them is proving difficult. So, it's when the user types in their browser https://www.subdomain.domain.com that ultimately fails with a privacy warning (our wildcard cert is for *.domain.com).
I've got a CNAME record set up pointing www.subdomain.domain.com to the A record for subdomain.domain.com. I've got the bindings in IIS set up for each of the 4 combinations (with/without https, with/without www).
I have the following in the config for the site:
<system.webServer>
<rewrite>
<rules>
<clear />
<rule name="Remove WWW" patternSyntax="Wildcard" stopProcessing="false">
<match url="*" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{CACHE_URL}" pattern="*://www.*" />
</conditions>
<action type="Redirect" url="{C:1}://{C:2}" redirectType="Permanent" />
</rule>
<rule name="http to https" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="true">
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="SeeOther" />
</rule>
</rules>
</rewrite>
</system.webServer>
Still it seems that I can't get the browser to like the redirect from the https://www.subdomain.domain.com to https://subdomain.domain.com. Why isn't the rewrite taking care of this before the browser attempts to serve www.subdomain.domain.com. Is this even possible??
I have a problem that I can't seem to find any solution to online. All searches are for http to https or non-www to www but without the http in front.
My site will not redirect https://domain.com to https://www.domain.com. It redirects domain.com to www.domain.com just fine though, it's only when the https is already entered does it not redirect and thus gives an error.
I have this for redirecting http to https:
<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}/{R:1}" />
</rule>
Edit: after experimenting, it manages to redirect http://domain.com to https://www.domain.com correctly (i.e from without s to with s and www).
Yet still doesn't from https://domain.com to https://www.domain.com
Figured it out, after adding this:
<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.domain.com/{R:1}" appendQueryString="true" redirectType="Permanent" />
</rule>
And most importantly, removing the hostname field 'www.domain.com in IIS > Site Bindings > Edit > Host Name, and unticking 'Require Server Name Indication'. Having my domain entered here was causing the above code to not work. I originally added this thinking it was necessary, but not so.
Suppose I have a site http://www.example.com which was 301 redirect from http://example.com to http://www.example.com.
Now after Google's recent update about using SSL for better rankings, I decided to use SSL.
I am using below code in web.config to 301 redirect to https
<rewrite>
<rules>
<rule name="Redirect to HTTPS" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://www.example.com/{R:1}" />
</rule>
</rules>
</rewrite>
now its redirecting 301 all requests http://www.example.com and http://example.com to https://www.example.com
but it's not redirecting https://example.com to https://www.example.com
I want to do this for only one canonical version as many SEO authority sites suggested.
If I use Plesk builtin functionality to redirect all non www to www, then it does double redirect.
How can I do this, Please help
Try a second rule to enforce the www, such as:
<rule name="Enforce WWW" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{CACHE_URL}" pattern="^https://(?!www)(.*)" />
</conditions>
<action type="Redirect" url="https://www.{C:1}" redirectType="Permanent" />
</rule>
The condition you have on your rule will stop it firing for a https request such as https://example.com.
Version #2 Try putting this before your other rule, the stopProcessing should stop it going circular.
<rule name="Enforce WWW" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="example.com" />
</conditions>
<action type="Redirect" url="https://www.example.com/{R:0}" />
</rule>
I am starting with the rewrite module have a problem with a "simple" IIS 8.5 URL Rewrite redirect http --> https for a non www site.
Problem: If the domain matches the action url parameter i always get "http://" and not "https://".
This is my rule:
<rewrite>
<rules>
<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="Permanent" />
</rule>
</rules>
</rewrite>
I can't post several links so "domain" = crm.test.com. The site with the rewrite rule is bound to "domain"=crm.test.com on port 2080.
I want to redirect "http://" to "https://", but i always get "http://" as location in response:
HTTP/1.1·302·Redirect
Connection:·close
Content-Length:·176
Date:·Thu,·15·Jan·2015·08:21:21·GMT
Location:·http://domain/ <--
Content-Type:·text/html;·charset=UTF-8
Server:·Microsoft-IIS/8.5
X-Powered-By:·ASP.NET
I tried the following action url parameter:
Not working:
"https://{HTTP_HOST}/{R:1}" -> http://domain/
"https://domain/{R:1}" -> http://domain/
"https://{HTTP_HOST}:443/{R:1}" -> http://domain/
"https://{HTTP_HOST}/1" -> http://domain/1/
Working:
"https1://{HTTP_HOST}/{R:1}" -> https1://domain/
"https://{HTTP_HOST}:444/{R:1}" -> https://domain:444/
"https://test.domain.com/{R:1}" -> https://test.domain.com/
"https://www.google.com/{R:1}" -> https://www.google.com/
I found "URL Rewrite on IIS from http to https is not working,", but this doesn't solve my problem.
Did i missed something?
The following works for us:
<rule name="HTTP Redirect to HTTPS" enabled="true" patternSyntax="ECMAScript" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" />
</rule>
O. k., i found the solution - the link translation is caused by a tmg 2010 in front of the iis. The tmg has a bug where the link translation resets the https links to http in case of a 301. Problem an solution are described here:
http://blog.sanibellogic.com/2008/09/default
http://support.microsoft.com/kb/924373
Thanks everybody.
You can also config the redirect domain with or without www using URL rewrite. The SSL cert only include: www FQDN.
web.config example (domain example is: sysadmit.com):
<rewrite>
<rules>
<clear />
<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.sysadmit.com/{R:1}" appendQueryString="true" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
Extracted from: http://www.sysadmit.com/2017/05/windows-iis-redirigir-http-https.html