troubleshooting Question

How to redirect a URL in IIS to fully qualified domain name and https

Avatar of Tom Grindrod
Tom Grindrod asked on
Microsoft IIS Web Server* URL Rewrite Rules
10 Comments1 Solution4170 ViewsLast Modified:
I'm trying to use the URL Rewrite module in IIS to redirect the four urls below. All but one are working but I can't figure out what is wrong.

1.) http://site1.company.com/web1  ->>   user is redirected correctly to:     https://site1.company.com/web1
2.) http://site1/web1  ->> user is redirected correctly to:    https://site1.company.com/web1
3.) https://site1.company.com/web1  ->> user goes to this site, no redirect needed
4.) https://site1/web1   ->>  This should redirect to https://site1.company.com/web1 but it does not work.  In the browser we get the ssl error that connection not valid.

Number 4 is not working. The same rule that sets the url in #2 should also do the job in #4. What am I missing?

Here are my two rules. I first add .company.com if it's not there and then add https if needed.

---- Here i the rule to add the FQDN:
<rule name="Redirect site1 to FQDN" enabled="true" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                        <add input="{HTTP_HOST}" pattern="^site1\.company\.com$" negate="true" />
                    </conditions>
                    <action type="Redirect" url="http://{HTTP_HOST}.company.com/{R:1}" redirectType="Permanent" />
                </rule>

----Here is the rule to change http to https:
                <rule name="Redirect Http to Https" 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>
ASKER CERTIFIED SOLUTION
Tom Grindrod

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 10 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 10 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros