I have a URL Rewrite rule in my web.config
:
<rewrite>
<rules>
<rule name="Redirect to www" patternSyntax="Wildcard" stopProcessing="true">
<match url="*"/>
<conditions>
<add input="{HTTP_HOST}" pattern="localhost" negate="true"/>
</conditions>
<action type="Redirect" url="https://www.example.com/{R:1}"/>
</rule>
</rules>
</rewrite>
The development URL in IISExpress is https://localhost:44301
The site has SSL enabled.
When running the app with Ctrl + F5 the condition isn't working and I am redirected to www.example.com.
If I change the pattern (add the port) to <add input="{HTTP_HOST}" pattern="localhost:44301" negate="true"/>
it works.
I don't want to add a condition for each of the different ports if you are for instance working in a team and different ports are being used in IISExpress for different developers. Is there a way to only specify localhost
as the pattern?