我的应用程序通常有两个域,一个用于应用程序,一个用于 API,如下所示 www.app.com <--- Angular running, web.config needs to rewrite everything to index.html api.app.com <--- my api
现在我想节省一些 ssl 成本并将逻辑更改为这样
www.app.com <--- the same www.app.com/api <--- api now here
我需要如何更改 web.config 才能使此配置生效?我正在为路线规则而苦苦挣扎
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="API Routes" ...>
<match url="...">
</rule>
<rule name="AngularJS Routes" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_URI}" pattern="^/(api)" negate="true" />
</conditions>
<action type="Rewrite" url="/" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
通过 IIS 管理器,您可以:
API Routes
部分添加规则。^api/(.*)
另外,删除这部分:
<add input="{REQUEST_URI}" pattern="^/(api)" negate="true" />