0
很抱歉的模糊標題,這個問題太複雜的短語來概括...IIS重寫規則跳過即使模式匹配
我試圖設置以下重定向規則:
blog.mydomain.net/en/something
:重定向到www.mydomain.com/something
blog.mydomain.net/fr/something
:重定向到www.mydomain.fr/something
blog.mydomain.net/*
:重定向到www.mydomain.com
規則3正在工作,但規則1和規則2似乎被跳過,所以總是應用規則3。下面是我的web.config規則:
<!-- Canonicalize mydomain.com to www.mydomain.com -->
<rule name="CanonicalHostNameRule_en" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTP_HOST}" pattern="^mydomain\.com$" />
</conditions>
<action type="Redirect" url="http://www.mydomain.com/{R:1}" />
</rule>
<!-- Canonicalize mydomain.fr to www.mydomain.fr -->
<rule name="CanonicalHostNameRule_fr" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTP_HOST}" pattern="^mydomain\.fr$" />
</conditions>
<action type="Redirect" url="http://www.mydomain.fr/{R:1}" />
</rule>
<!-- Redirect blog.mydomain.net/en/something to www.mydomain.com/something -->
<rule name="RedirectBlog_en" enabled="true" stopProcessing="true">
<match url="^/en(/.*)?$" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTP_HOST}" pattern="^blog\.mydomain\.net$" />
</conditions>
<action type="Redirect" url="http://www.mydomain.com/{R:1}" />
</rule>
<!-- Redirect blog.mydomain.net/fr/something to www.mydomain.fr/something -->
<rule name="RedirectBlog_fr" enabled="true" stopProcessing="true">
<match url="^/fr(/.*)?$" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTP_HOST}" pattern="^blog\.mydomain\.net$" />
</conditions>
<action type="Redirect" url="http://www.mydomain.fr/{R:1}" />
</rule>
<!-- Redirect blog.mydomain.net/* to www.mydomain.com -->
<rule name="RedirectBlog_other" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTP_HOST}" pattern="^blog\.mydomain\.net$" />
</conditions>
<action type="Redirect" url="http://www.mydomain.com/" />
</rule>
<!-- Wordpress-specific rules -->
...
我不明白爲什麼規則RedirectBlog_en
和RedirectBlog_fr
會被跳過;我測試了正則表達式,它們工作正常。
任何人都可以發現問題嗎?
編輯:如果我禁用第三規則(RedirectBlog_other),那麼規則1和2,做工精細......這怎麼可能,因爲規則1和2規則3之前執行?