小编Cap*_*net的帖子

Web.config URL重写 - 强制www前缀和https

我正在尝试强制执行https和www前缀.但是我的规则并不完全有效.这是我的规则:

<rewrite>
  <rules>
    <clear />             
    <rule name="Force https" stopProcessing="true">
      <match url="(.*)" />
      <conditions>
            <add input="{HTTPS}" pattern="off" ignoreCase="true" />
      </conditions>
      <action type="Redirect" url="https://www.mydomain.co.uk/{R:1}" redirectType="Permanent" />
    </rule>
    <rule name="Force www" stopProcessing="true">
      <match url="(.*)" />
      <conditions>
            <add input="{HTTP_HOST}" pattern="localhost" negate="true" />
            <add input="{HTTP_HOST}" pattern="www.mydomain.co.uk" negate="true" />
      </conditions>
      <action type="Redirect" url="https://www.mydomain.co.uk/{R:1}" redirectType="Permanent" />
    </rule>          
  </rules>
</rewrite>
Run Code Online (Sandbox Code Playgroud)

有人可以建议吗?谢谢.

asp.net web-config url-rewriting

1
推荐指数
1
解决办法
4604
查看次数

标签 统计

asp.net ×1

url-rewriting ×1

web-config ×1