I'm trying to create a url rewrite in IIS. We have installed a SSL cert on the server and need all connections to be HTTPS. The HTTPS rewrite rule seems to be working properly.
The issue we have is that users throughout the organization have bookmarks for the server name. Because of this, they will receive a security warning about the server name not matching the certificate. Example: https://mywebserver/BI/Default.aspx.
I need to rewrite the domain so that they are redirect to https://mywebserver.abcxyz.com/BI/Default.aspx
The current rules that I have created will redirect to HTTPS. It will also rewrite the domain from https://mywebserver/ to https://mywebserver.abcxyz.com.
The problem I have is that it will not work if anything comes after the server name. Example of domain that will not work: http://mywebserver.abcxyz.com/BI/Default.aspx
Any suggestions? This is what I currently have in my web.config.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="CanonicalHostNameRule1" enabled="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^mywebserver\.abcxyz\.com$" negate="true" />
</conditions>
<action type="Redirect" url="http://mywebserver.abcxyz.com/{R:1}" />
</rule>
<rule name="Redirect to HTTPS" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="SeeOther" />
</rule>
</rules>
</rewrite>
</system.webServer>