2

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?

PussInBoots
  • 11,028
  • 9
  • 52
  • 84
  • If everyone uses a different port (meaning their project files are in different state), I see no reason why they cannot have `web.config` in different state. If you want a single copy of `web.config` to be used, you should use the same port (which is not difficult to achieve as IIS Express uses 443**). – Lex Li Jul 16 '15 at 12:52

0 Answers0