Skip to content

Instantly share code, notes, and snippets.

@pnutmath
Last active March 5, 2019 06:25
Show Gist options
  • Save pnutmath/c54307cdab2009ae320559c7123d8f9b to your computer and use it in GitHub Desktop.
Save pnutmath/c54307cdab2009ae320559c7123d8f9b to your computer and use it in GitHub Desktop.
Angular Deployment on IIS

Deploy Angular Application on IIS

To work PathLocationStrategy we need to provide rewrite rules

If the app uses the Angular router, you must configure the server to return the application's host page (index.html) when asked for a file that it does not have.

  • Add web.config file in src/ folder
  • add web.config file name in assets of angular.json file so it will available in output folder after build

Must be set <base href=""/> in index.html

<?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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment