【发布时间】:2016-12-05 21:23:47
【问题描述】:
This is my project structure. I have index.html outside app folder. 当我在本地运行我的应用程序时,它可以正常工作。 Angular2 路由和页面渲染在本地机器上正常工作。
但是当我在服务器上托管这个应用程序时。页面路由不起作用。
我在我的 web .config 中包含以下代码来重写 URL,然后我可以将 index.html 页面称为默认页面。
`
<system.webServer>
<rewrite>
<rules>
<rule name="Angular2" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" pattern="" ignoreCase="false" />
</conditions>
<action type="Rewrite" url="/index.html" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
`
但尚未渲染 angular2 页面。
我还在根域中发布了我的应用程序。并在 index.html 页面中也包含<base href="/">。
请建议我该怎么做?
【问题讨论】:
-
错误是什么?你去那里看到什么?
-
用的是什么transpile呢?这是打字稿吗? dist 文件夹在哪里?
-
@xe4me 我正在使用打字稿来转换它。在服务器上我没有看到任何错误。仍然没有加载由角度 2 路由的我的内页。
标签: html .htaccess angular iis angular2-routing