V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
alex321
V2EX  ›  问与答

Redirect 正常的情况下, IIS 的 Rewrite 为啥会给我个 404?

  •  
  •   alex321 · Aug 28, 2018 · 1062 views
    This topic created in 2811 days ago, the information mentioned may be changed or developed.

    情况描述如下,SOF 上也翻了一遍,不得要领。请教下各位大佬。。

    环境

    IIS 7.5(IIS_UrlRewriteModule 7.1.0871.0) + CI 3.1.9 + PHP 5.6.37

    Web.config

    <rule name="rule1" stopProcessing="true">
    	<match url="^uploads/?$|^uploads/(.*)$" />
    	<action type="Rewrite" url="index.php/home/attach.html?id=uploads/{R:1}" appendQueryString="true" logRewrittenUrl="false" />
    </rule>
    <rule name="rule2" stopProcessing="true">
    	<match url="^(.*)$" />
    	<conditions logicalGrouping="MatchAll">
    		<add input="{HTTP_HOST}" pattern="^(.*)$" />
    		<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
    		<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
    	</conditions>
    	<action type="Rewrite" url="index.php/{R:1}" />
    </rule>
    

    请求 URL

    http://example.com/uploads/testf6acf1d64660ea738bcf9163320b3b7f.png

    使用 Redirect 配置 Web.config 中 rule1 下的 action 的 type

    正常跳转到 http://example.com/index.php/home/attach.html?id=uploads/testf6acf1d64660ea738bcf9163320b3b7f.png ,显示 attach 文字,内容正确。

    使用 Rewrite 配置 Web.config 中 rule1 下的 action 的 type

    显示 CI 默认的 404 页。

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5354 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 40ms · UTC 07:54 · PVG 15:54 · LAX 00:54 · JFK 03:54
    ♥ Do have faith in what you're doing.