angular2不在服务器上加载页面,同样的东西在本地机器上工作

时间:2016-12-03 07:37:00

标签: html .htaccess angular iis angular2-routing

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="/">

请建议我该怎么办?

1 个答案:

答案 0 :(得分:1)

最后我找到了解决方案。我的内部网络(防火墙)阻止我的角度2应用程序加载动态页面。在网络人员的帮助下,我解决了这个问题。

除了它之外,还需要URL重写和基本路径来加载服务器上的角度应用程序。

感谢。

相关问题