V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
alex321
V2EX  ›  问与答

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

  •  
  •   alex321 · 2018-08-28 11:35:12 +08:00 · 789 次点击
    这是一个创建于 2089 天前的主题,其中的信息可能已经有所发展或是发生改变。

    情况描述如下,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 页。

    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1003 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 22:23 · PVG 06:23 · LAX 15:23 · JFK 18:23
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.