angular - Angular 7 组件。404 - 找不到文件或目录
问题描述
我有一个名为 r 的组件,它通过查询字符串接收一个名为 a 的参数。当我从 VS Code 尝试它时,它工作得很好。后来我使用 Windows 和 IIS 在我的服务器上发布它并打开页面https://mypage/r?A= Fl,浏览器返回 404 - 找不到文件或目录。但是存在 R 分量。
你怎么能解决这个问题?我感谢您的帮助。
解决方案
我能够解决它,我需要将以下内容添加到 web.config 文件中。
<? xml version = "1.0" encoding = "utf-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name = "Angular Routes" 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 = "./ index.html" />
</ rule>
</ rules>
</ rewrite>
</system.webServer>
</ configuration>
推荐阅读
- ios - iOS 应用程序中的 Apple Pay 是否需要像 Stripe 这样的支付处理程序?
- python - 如果会话中还剩下更多,reqHistoricalTicks 是否应该返回 0 个刻度?
- java - 对象引用等于检查 LRU 缓存实现
- git - 无法在 gke 集群上部署带有通量的 Git 存储库接收器
- oracle - 在 oracle pl/sql 中转换日期字符串
- javascript - Node js和heroku变量存储问题
- reactjs - zsh:找不到命令:Mac OS 上的 netlify
- html - 反向迭代表(vue)
- android - Android:MediaPlayer onPrepared 不工作
- javascript - 在 Vue3 中使用 ChartJs /not vue-chartjs/