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

2018-08-28 11:35:12 +08:00
 alex321

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

792 次点击
所在节点    问与答
0 条回复

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/483894

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX