簡體   English   中英

IIS 重定向映射不適用於根目標

[英]IIS redirect maps not working for root destination

當我將目標指向 root 時,我在讓 rewrite pas 正常工作時遇到了一些麻煩。

如果我指向 /page/ 目的地 t 似乎可以正常工作,但如果我指向 / 則不會。 以下是我在 web.config 中的內容

    <rewrite>
    <rewriteMaps>
        <rewriteMap name="StaticRewrites">
            <add key="/1" value="/article.aspx?id=1&amp;title=some-title" />
            <add key="/random_page.htm" value="/" />
            <add key="/friends.htm" value="index.php" />
            <add key="/page_2.htm" value="/index.php" />
            <add key="/some_other_page.htm" value="/some_other_page/" />
            <add key="/some_page_test.htm" value="/test21.php" />
            <add key="/2nd_page_test.htm" value="/test.txt" />
            <add key="/3rd_page_test" value="/test1.htm" />
            <add key="/4th_page_test.htm" value="article.aspx?id=1&amp;title=some-title" />
            <add key="/root_page_again.htm" value="/" />
        </rewriteMap>
</rewriteMaps>
<rules>     
    <rule name="Rewrite rule1 for StaticRewrites">
            <match url="(.*)" />
            <conditions>
                <add input="{StaticRewrites:{REQUEST_URI}}" pattern="(.+)" />
            </conditions>
            <action type="Rewrite" url="{C:1}" appendQueryString="false" />
    </rule>
    <rule name="WordPress: http://123.123.12.123" patternSyntax="Wildcard">
        <match url="*" />
        <conditions>
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
        </conditions>
            <action type="Rewrite" url="index.php/{R:0}" />
    </rule>     
</rules>
</rewrite>

第一個作品
第二、第三、第四個不起作用
第 5、6、7、8 和 9 號確實有效
第 10 個或最后一個沒有

我為 IIS 8.5 的隱私編輯了一些明顯的地方

第一個有效,因為它匹配第一條規則。

第二個不起作用,因為您沒有設置默認文檔。 它匹配第一條規則,如果您設置默認文檔,它將重寫為 http://localhost:xx/ 並顯示默認文檔。

第三條和第四條匹配第一條規則,都改寫為http://localhsot:xx/index.php

第 5、6、7、8 條都符合第 1 條和第 2 條規則,但重寫為 http://localhsot:xx/index.php//”value” 並顯示 index.php。

第 9 條匹配第 1 條規則並重寫為 http://localhsot:xx/article.aspx?id=1&title=some-title。

第 10 次與第 2 次相同。

您可以打開失敗請求跟蹤,它會記錄整個重寫過程,包括是否符合規則以及是否重寫。

我很抱歉我沒有發布配置文件的開頭。 我假設每個人都會理解默認文檔已被設置,因為沒有它整個站點將無法加載。

這是我之前沒有發布的 web.config 的開始部分

    <configuration>
  <system.webServer>
    <defaultDocument>
      <files>
        <add value="index.php" />
      </files>
    </defaultDocument>
    <rewrite>
    <rewriteMap name="StaticRewrites">

我感謝在這件事上的任何幫助,並且知道我必須遺漏一些簡單的東西,因為大多數規則實際上都有效

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM