This section covers changes you may have to make to the server or to files deployed on the server.
To view the original content please navigate to https://angular.io/guide/deployment#server-configuration.
Routed apps must fallback to
Angular apps are perfect candidates for serving with a simple static HTML server. You don't need a server-side engine to dynamically compose application pages because Angular does that on the client-side.
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.
A routed application should support "deep links". A deep link is a URL that specifies a path to a component inside the app. For example,
is a deep link to the hero detail page that displays the hero with
There is no issue when the user navigates to that URL from within a running client. The Angular router interprets the URL and routes to that page and hero.
But clicking a link in an email, entering it in the browser address bar, or merely refreshing the browser while on the hero detail page — all of these actions are handled by the browser itself, outside the running application. The browser makes a direct request to the server for that URL, bypassing the router.
A static server routinely returns
index.html when it receives a request for
http://www.mysite.com/. But it rejects
and returns a
404 - Not Found error unless it is configured to return
Fallback configuration examples
There is no single configuration that works for every server. The following sections describe configurations for some of the most popular servers. The list is by no means exhaustive but should provide you with a good starting point.
Apache: add a rewrite rule to the
.htaccessfile as shown (https://ngmilk.rocks/2015/03/09/angularjs-html5-mode-or-pretty-urls-on-apache-using-htaccess/):
- Example web.config: