相关疑难解决方法(0)

xdt:Transform ="Insert"不适用于<system.webServer>中的<rewrite>

我在web.config的live配置中编写了以下转换.

<system.webServer>
    <rewrite xdt:Transform="Insert">
      <rules>
        <rule name="httpsrewrite">
          <match url=".*" />
          <serverVariables>
            <set name="SERVER_PORT" value="443" />
            <set name="HTTPS" value="on" />
          </serverVariables>
          <action type="None" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
Run Code Online (Sandbox Code Playgroud)

我的web.config中没有元素.

转换不起作用.我所有的其他转换(替换为elmah和连接字符串)工作正常.

asp.net-mvc web-config asp.net-mvc-4 xdt-transform web.config-transform

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

HTTP到HTTPS重定向 - IIS 8.5无法正常工作

我在SO以及'net(IIS博客等)上阅读了很多帖子.我试图强制所有连接从domain.com到www.domain.com,同时强制从HTTP到HTTPS的请求.

我正在使用这组规则并重写,但唯一发生的事情是它重定向正常但不重定向到SSL.

<!-- Redirect to HTTPS -->
<rewrite>
    <rules>
        <rule name="Redirect to www" stopProcessing="true">
            <match url="(.*)" />
            <conditions trackAllCaptures="false">
                <add input="{HTTP_HOST}" matchType="Pattern" pattern="^mydomain.com$" ignoreCase="true" negate="false" />
            </conditions>
            <action type="Redirect" url="{MapProtocol:{HTTPS}}://www.mydomain.com/{R:1}" />
        </rule>
    </rules>
    <rewriteMaps>
        <rewriteMap name="MapProtocol" defaultValue="http">
          <add key="on" value="https" />
          <add key="off" value="http" />
        </rewriteMap>
    </rewriteMaps>
</rewrite>
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?

主要博客参考:http://weblogs.asp.net/owscott/url-rewrite-protocol-http-https-in-the-action和这个SO post- web.config将非www重定向到www

iis redirect iis-8.5

8
推荐指数
3
解决办法
2万
查看次数