Asp.net 在发布配置中插入重写规则
嗨,我想为“重定向到HTTPS”插入重写规则,但只在我的发布配置上 这就是重写规则的外观Asp.net 在发布配置中插入重写规则,asp.net,xslt,web-config-transform,xdt-transform,Asp.net,Xslt,Web Config Transform,Xdt Transform,嗨,我想为“重定向到HTTPS”插入重写规则,但只在我的发布配置上 这就是重写规则的外观 <system.webServer> <rewrite> <rules> <rule name="Redirect to HTTPS"> <match url="(.*)" /> <conditions>
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect to HTTPS">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
<add input="{URL}" pattern="/$" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
</conditions>
<action type="Redirect" url="https://{SERVER_NAME}/{R:1}" redirectType="SeeOther" />
</rule>
</rules>
</rewrite>
</system.webServer>
如何仅在my release.config中实现这一点?您可以查看web.config转换: 创建和编码转换文件的步骤
只需在需要插入web.config发布版本的元素上添加
xdt:Transform=“Insert”
属性。例如,如果初始web.config根本不包含
元素,则release.config应如下所示:
<system.webServer>
<rewrite xdt:Transform="Insert">
<rules>
<rule name="Redirect to HTTPS">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
<add input="{URL}" pattern="/$" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
</conditions>
<action type="Redirect" url="https://{SERVER_NAME}/{R:1}" redirectType="SeeOther" />
</rule>
</rules>
</rewrite>
</system.webServer>
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect to HTTPS" xdt:Transform="Insert">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
<add input="{URL}" pattern="/$" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
</conditions>
<action type="Redirect" url="https://{SERVER_NAME}/{R:1}" redirectType="SeeOther" />
</rule>
</rules>
</rewrite>
</system.webServer>