【发布时间】:2021-07-14 12:56:03
【问题描述】:
我正在尝试使用 IIS URL Rewrite 来重写:
http://localhost/RESTDemo/Service1.svc/Persons 到 http://localhost/RESTDemo/api/Persons
我的 Web.config 中有以下配置:
<system.webServer>
<rewrite>
<rules>
<rule name="Change 'Service1.svc' to 'api'" stopProcessing="true">
<match url="^(.*)/RESTDemo/api/(.*)$" />
<action type="Rewrite" url="{R:1}/RESTDemo/Service1.svc/{R:2}" logRewrittenUrl="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
但是当我测试 POST 到 http://localhost/RESTDemo/api/Persons 时,我从 IIS 中得到 404.0 Not Found。然后,当我尝试对 http://localhost/RESTDemo/Service1.svc/Persons 运行相同的 POST 时,它可以工作。
我尝试检查C:\inetpub\logs\LogFiles\W3SVC1 下的日志,但看不到任何有用的信息,即使我设置了logRewrittenUrl="true",我也只能在我的 IIS 日志中看到:
2021-04-20 10:18:48 127.0.0.1 POST /RESTDemo/api/persons - 80 - 127.0.0.1 Apache-HttpClient/4.5.5+(Java/12.0.1) - 404 0 2 1
我的问题是……
- 我做错了什么?
- 为什么我在日志文件中看不到重写的 URL?
【问题讨论】:
-
从错误1开始blog.lextudio.com/…
标签: url-rewriting biztalk iis-10