【发布时间】:2017-08-09 16:37:01
【问题描述】:
我不确定这个标题是否有意义,但为了进一步解释,我有一个网站,每个请求都需要访问我的名为 controller.php 的文件。
这个工作我已经有一段时间了,今天包含 pdf 文件的新目录被添加到站点中。目前该目录中有两个文件可通过超链接访问。
我访问的两个相对路径是:http://q360help.joehelp.com/Docs/Document_Grid_Filters.pdf
正确重定向到:
http://q360help.joehelp.com/controller.php?Docs/Document_Grid_Filters.pdf
与
http://q360help.joehelp.com/Docs/SERVERDATA.pdf
这是应该到但目前不重定向到:
http://q360help.joehelp.com/controller.php?Docs/SERVERDATA.pdf
相反,当尝试访问任何不通过控制器的内容时,我会收到 404 错误。当我手动将 controller.php 添加到 URL 时,文件加载正常。我只是好奇为什么它没有正确重定向。每个其他目录中的每个其他 pdf 文件都可以正常工作。
这是我的 web.config 文件:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<httpRedirect enabled="false" destination="" />
<rewrite>
<rules>
<rule name="controller redirect" enabled="true" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(http://)?(www.)?joehelp.com" negate="true" />
<add input="{HTTP_HOST}" matchType="Pattern" pattern="^(http://)?(www.)?q360help.joehelp.com$" ignoreCase="true" negate="false" />
<add input="{URL}" pattern="Data/*" negate="true" />
<add input="{URL}" pattern="Skins/*" negate="true" />
<add input="{URL}" pattern="Resources/*" negate="true" />
<add input="{PATH_INFO}" pattern="^/controller.php*$" negate="true" />
</conditions>
<action type="Redirect" url="/controller.php?{R:0}" />
</rule>
</rules>
</rewrite>
<httpErrors errorMode="Detailed" />
</system.webServer>
编辑: 经过进一步测试,似乎在 URL 中的任何位置都有“数据”一词是导致此问题的原因。这是一回事吗?我从未听说过这样的事情,并且通过 IIS 中的 GUI 使用 URL 重定向模式测试器表明 URL 应该 重定向。
此时我的解决方法是更改文件名,使其中没有“数据”,但我很想知道为什么会发生这种情况。
【问题讨论】:
标签: php .htaccess iis url-rewriting web-config