Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

angular部署到iis出现404 #16

Closed
WeihanLi opened this issue Jun 25, 2018 · 1 comment
Closed

angular部署到iis出现404 #16

WeihanLi opened this issue Jun 25, 2018 · 1 comment

Comments

@WeihanLi
Copy link
Owner

angular应用部署在iis上,刷新出现404

解决方案:

安装 iis URL Rewrite 模块,配置urlrewrite如下:

在 src 目录下增加web.config,内容如下:

<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="/" />
      </rule>
    </rules>
  </rewrite>
</system.webServer>
</configuration>

配置 web.config 自动打包

修改 angular-cli.json文件(angular2-5)

  "apps": [
        {
	   "root": “src”,
	   "ourDir": “dist”,
	   "assets": [
	      “assets”,
	      “favicon.ico”,
	      “web.config”
          ],

修改 angular.json 文件(angular6)

        “build”: {
	   "options”: {
	     . . . 
	     "assets": [
	        “src/assets”,
	        “src/favicon.ico”,
	        “src/web.config”
             ],

Reference

@WeihanLi WeihanLi added the FE label Jun 25, 2018
@WeihanLi
Copy link
Owner Author

WeihanLi commented Jun 25, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant