我正在尝试将两个 Angular 应用程序部署到一个应用程序服务计划,其中一个应用程序可通过 baseurl 访问,另一个应用程序可通过 baseurl/app1 访问
我能够使用虚拟目录路径映射让它工作。但问题是,当我尝试执行 baseurl/app1/route 时, Angular 深度路由无法访问。
<rewrite>
<rules>
<rule name="Angular routing to checkout" stopProcessing="true">
<match url="^app1/.*"/>
<conditions logicalGrouping="MatchAll">
</conditions>
<action type="Rewrite" url="/app1/" appendQueryString="true"/>
</rule>
</rules>
</rewrite>
我需要一种方法让 Angular 应用程序处理/app1/route 的内部路由。
最佳答案
这个 web.config
对我有用:
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="app2" stopProcessing="true">
<match url="^app2/.*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="/app2/" />
</rule>
<rule name="app" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="/" />
</rule>
</rules>
</rewrite>
<caching enabled="true" enableKernelCache="true">
<profiles>
<add extension=".js" policy="DisableCache" kernelCachePolicy="DisableCache" />
</profiles>
</caching>
</system.webServer>
</configuration>
在我的 appService 中它看起来像这样:
-- wwwroot // angular build of main app
-- wwwroot_app2 // angular build of second app available on /app2
我将 web.config
保存在 wwwroot
中。如果我没记错的话,appService 中只有一个 web.config
文件很重要。
还请记住在第二个应用程序中正确设置 baseHref
和 deployUrl
。
https://stackoverflow.com/questions/56318892/
相关文章:
android-security - Google Play - 不安全解压缩模式漏洞的安全警报
selenium - 在失败场景的范围报告 4 中添加屏幕截图
google-cloud-build - Google Cloud Build - Github 触
json-rpc - 在 json-rpc Web 服务上返回 Auth 错误代码
java - 如何更改日期时间选择器对话框中天数的文本大小?
c# - 如何获取在 asp.net 中使用我的 web api 的请求 url?
sqlite - 升级 SQFLITE : Unhandled Exception: Databas
visual-studio-code - vscode 给出的建议的部分自动完成?