I’ve received my ssl certificate on a shared hosting provided and installed it successfully. The certificate is prepared for mysite.com, not for *.mysite.com.
I want the site to be accessible like https : // mysite.com – no www, no http (only secure connections). I’ve found similar questions here, but not the right one.
I’m using IIS 7, .net environment. The following rules were added my web.config:
<rule name="Remove WWW prefix">
<match url="(.*)" ignoreCase="true" />
<conditions>
<add input="{HTTP_HOST}" pattern="^www\.mysite\.com" />
</conditions>
<action type="Redirect" url="https://mysite.com/{R:1}" redirectType="Permanent" />
</rule>
<rule name="Redirect to HTTPS">
<match url="(.*)" />
<conditions>
<add input="{SERVER_PORT}" pattern="443" negate="true" />
</conditions>
<action type="Redirect" url="https:// mysite.com/{R:1}" />
Everything is working fine, but the url https://www.mysite.com is not redirected to https://mysite.com. I get the error that the certificate is for mysite.com (which was intended :), the message comes from firefox) with the advice to add exception.
My question is what is the appropriate rule for this url?
Thank you in advance for your time.
Unfortunately I don’t think you can do this. You need a valid SSL certificate on https://www.mysite.com to get redirected to https://mysite.com without warning the user about an invalid certificate. IIS will attempt to negotiate the SSL connection before URL Rewrite has a chance to act on it.
You could possibly do this with a DNS entry. You could add a CNAME entry that looks like this: