简体   繁体   中英

how to set asp.net web.config rewrite http to https and www to non-www

I m very noob on the rewrite part, hope someone can help me. Now im using this

<rewrite>
  <rules>
    <rule name="Imported Rule 1" stopProcessing="true">
      <match url="^(.*)" ignoreCase="false" />
      <conditions logicalGrouping="MatchAll">
        <add input="{HTTPS}" negate="true" pattern="^on$" ignoreCase="false" />
      </conditions>
      <action type="Redirect" url="https://{SERVER_NAME}/{R:1}" redirectType="Found" />
    </rule>
  </rules>
</rewrite>

This only can change http to https only, now I hope it can support to change www to non-www too. What should I do to do it?

Why from web.config? You should allow it from IIS - just add it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM