php - 使用 url rewrite 模块创建规则将所有流量重写到 php
问题描述
我遇到的问题是我无法正确访问我的api的端点,总是返回404或403。api是在iis 8中用slim创建的,结构如下:
我的 web.config 位于 /v1/Web.config 中(图中项目的末尾),其代码如下:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="rule" 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.phk" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
我需要当用户调用url“ http://myserverip/api/v1 ”时去公共文件夹中找到index.phk文件,不管用户调用端点还是root/v1,它都有总是去 index.phk。感谢您的关注,对不起我的英语。
解决方案
很确定块logicalGrouping
内属性的默认值是,因此默认情况下 IIS 会尝试匹配既是文件又是目录的请求。如果您插入应该匹配任一条件:<conditions/>
MatchAll
logicalGrouping="MatchAny"
<conditions logicalGrouping="MatchAny">
另外,你的动作需要前导/
,我不会提到你拼写index.php
index.phk
...
<action type="Rewrite" url="/index.php" />
推荐阅读
- ios - Firebase Auth iOS 用户匿名创建但未在控制台中显示
- git - 在 git 中合并拉取请求会导致上游分支领先于原点
- c - 编译 lex 生成的文件时 errno.h(及更多)中的错误
- angular - 基于输入在组件之间传递信息
- php - PDO fetchAll() - 使用 JOIN 时 json_encode 不起作用
- python - Django + Apache - [核心:错误] [pid 10696] [客户端
:35768] 脚本在返回标头之前超时:wsgi.py - c# - Visual Studio:将参数传递给编译器生成后事件中的可执行文件
- ibm-watson - Watson Assistant 启动工具
- ios - 如何将多个 docs/pdf 文件从 iOS 应用程序同时上传到 AWS
- python - 如何使用 Pyserial 从 Arduino 接收 5 位数据?