[英]IIS 7.5 URL Rewrite: Is there a better way to rewrite / combine multiple rules
[英]Multiple IIS7 URL Rewrite rules
我正在嘗試編寫IIS7 URL Rewrites規則,該規則可做兩件事:
在兩種情況下,我都想重定向到https://my.domain.com (用真實域名代替)
我的http to https規則沒有問題。 同樣,從http://www.my.domain.com到https://my.domain.com的情況也適用。 但是,我無法上班的一種情況是原始請求發送到https://www.my.domain.com時
這是我現在所擁有的:
<rule name="r2" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{SERVER_PORT}" pattern="443" negate="false" matchType="Pattern" />
<add input="{HTTP_HOST}" pattern="^(www\.)(.*)$" matchType="Pattern" />
</conditions>
<action type="Redirect" url="https://my.domain.com" />
</rule>
<rule name="r1" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{SERVER_PORT}" pattern="443" negate="true" matchType="Pattern" />
<add input="{HTTP_HOST}" pattern="^(www\.)(.*)$" matchType="Pattern" />
</conditions>
<action type="Redirect" url="https://my.domain.com" />
</rule>
我需要更改以使https://www.my.domain.com重定向到https://my.domain.com的任何想法?
試試這個對我有用
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="permalink">
<match url="article/(\D+)(\/)*$" />
<action type="Rewrite" url="http://mywebsite.com/article.aspx?id={R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
這可能對你有用
<rule name="Canonical Host Name" stopProcessing="true">
<match url="(.*)"/>
<conditions>
<add input="{HTTP_HOST}" pattern="https://mydomain.com$"/>
</conditions>
<action type="Redirect" url="https://www.mydomain.com/{R:1}" redirectType="Permanent"/>
</rule>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.