【发布时间】:2017-01-06 16:59:31
【问题描述】:
我的应用在尝试访问路由时出现错误(404 未找到):
$app->get('/test/', function () {
echo "Hello, World! test";
});
但是没关系,尝试访问时:
$app->get('/', function () {
echo "Hello, World!";
});
需要配置 Allowoverride All 吗? 我该怎么做,使用 web.config IIS?]
更新.. 我用代码创建 web.config 文件: 现在不使用 htaccess,只有 web.config .. 但仍然无法正常工作
URL 重写模块错误。
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="slim" 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" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
【问题讨论】:
-
你的
RewriteCond %{REQUEST_FILENAME} !-d条件意味着如果文件夹存在,就不要重写。从您的$app->get()代码中,很明显文件夹/路径/test/要么不存在,要么没有适当的权限。此外,您正在尝试在 IIS 服务器上使用.htaccess-- 您可能希望查看 translate htaccess content to iis webconfig -
@KraangPrime 更新请检查
-
你有rewrite module installed并启用了吗?
-
我不认为..请问怎么办?
-
查看我上一条评论中的链接。这是一个显示如何安装它的解决方案的链接。
标签: php rest iis web-config slim