Iis – How to redirect or rewrite IIS site with port in URL to URL without port

iisiis-7redirectrewritewindows-server-2008

I'm not 100% sure if this is the right part of StackOverflow to post this but to me it made the most sense. Sorry if its not!

Currently I have a site in IIS configured on HTTPS with port 7500. I can access this site by using the URL: https://portal.company.com:7500.

What I would like to do is remove the port number at the end of the URL so users can access this site using https://portal.company.com

I am a complete beginner with IIS, but what I have tried is the HTTP Redirect, which if I used on this IIS site, would redirect a user that hits portal.company.com:7500 to some other site, which is not what I need. Another thing I have though about is creating another IIS site which serves the purpose of being at the URL portal.company.com and when its hit, it redirects to my portal.company.com:7500, but I don't know if this is the best approach.

So my question is, what are my options for achieving the behavior mentioned above and what is the best/recommended approach?

I haven't played with URL Rewriting before but I will look into that now while I wait for a reply. Thanks!!

Using IIS Manager on a Windows Server 2008 machine.

Best Answer

Try This

<configuration>
<system.webServer>
    <rewrite>
           <rules>
            <rule name="removePort" stopProcessing="true">
                <match url="^(http(s)?://)?(portal\.company\.com):7500(/.*)?$" />
                <action type="Redirect" url="https://{R:3}/{R:4}" />
            </rule>
        </rules>
    </rewrite>
</system.webServer>