bey*_*eyz 4 iis redirect web-config
我想让所有页面从 HTTP 重定向到 HTTPS,除了根目录中的一个页面 (pagename.php),该页面需要作为 HTTP 工作(需要重定向回 HTTP)。我目前有以下代码可以从 none-www 重定向到 www 以及从 HTTP 重定向到 HTTPS。
<rewrite>
<rules>
<rule name="Redirect to WWW" stopProcessing="true" >
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^www\." negate="true"/>
</conditions>
<action type="Redirect" url="https://www.{HTTP_HOST}{HTTP_URL}" redirectType="Permanent" appendQueryString="false" />
</rule>
<rule name="Redirect to HTTPS">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="OFF"/>
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{HTTP_URL}" redirectType="Permanent" appendQueryString="false" />
</rule>
</rules>
<outboundRules>
<rule name="Add Strict-Transport-Security when HTTPS" enabled="true">
<match serverVariable="RESPONSE_Strict_Transport_Security"
pattern=".*" />
<conditions>
<add input="{HTTPS}" pattern="on" ignoreCase="true" />
</conditions>
<action type="Rewrite" value="max-age=31536000" />
</rule>
</outboundRules>
</rewrite>Run Code Online (Sandbox Code Playgroud)
我需要此角色中的其他角色或异常来重写或将特定 URL 重定向到 HTTP(我只需要 2 个 URL 来作为 HTTP 工作,并且它们只是具有 .php 页面扩展名的 URL,所有其他 URL 都不同)。
我非常感谢您对此的帮助。
您需要一个带有 negate="true" 的条件来为您的 php 文件添加例外。
<rule name="Redirect to HTTPS">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="OFF"/>
<add input="{URL}" pattern="(.*).php" negate="true" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{HTTP_URL}" redirectType="Permanent" appendQueryString="false" />
</rule>
<!--EDIT-->
<rule name="Redirect to HTTP">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="ON"/>
<add input="{URL}" pattern="(.*).php" />
</conditions>
<action type="Redirect" url="http://{HTTP_HOST}{HTTP_URL}" redirectType="Permanent" appendQueryString="false" />
</rule>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4365 次 |
| 最近记录: |