【发布时间】:2016-09-23 01:34:47
【问题描述】:
http://www.iis.net/learn/extensions/url-rewrite-module/url-rewrite-module-configuration-reference
<rule name="AngularJS Routes" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
</conditions>
<action type="Rewrite" url="/index.html" />
</rule>
以上是针对 Angular 单页应用程序广泛建议的几个 url 重写规则之一。 我理解该规则的意思是“如果请求不是针对物理文件,请将 url 重写为 /index.html。
摘自以上文档链接:“这可用于指定检查请求的 URL 是否不是文件的条件...”
在 index.html 我有这个脚本参考:
<script src="lib/jquery/dist/jquery.min.js"></script>
这是一个物理文件,它确实存在于指定位置的磁盘上。
重写规则是接收这个请求并将其重写到 /index.html。
为什么会这样?
我的 web.config 与 wwwroot 位于同一级别。
github上有几个与url重写相关的线程,不确定是否涵盖了这个特定问题: https://github.com/aspnet/BasicMiddleware/issues/43 https://github.com/aspnet/IISIntegration/issues/164 https://github.com/aspnet/IISIntegration/issues/192
【问题讨论】:
标签: url-rewriting asp.net-core .net-core