config your app route to use hash #
const routes: Routes = [
// routes here
];
@NgModule({
imports: [
... other imports
RouterModule.forRoot(routes, { useHash: true }) // .../#/users/
],
...
})
export class SomeModule { }
or configure S3
In the Edit Redirection Rules section of the S3 Console for your domain, add the following rules:
<RoutingRules>
<RoutingRule>
<Condition>
<HttpErrorCodeReturnedEquals>404</HttpErrorCodeReturnedEquals>
</Condition>
<Redirect>
<HostName>domain.com</HostName>
<ReplaceKeyPrefixWith>#/</ReplaceKeyPrefixWith>
</Redirect>
</RoutingRule>
</RoutingRules>
put this in index.html
<script language="javascript">
if (typeof(window.history.pushState) == 'function') {
window.history.pushState(null, "Site Name", window.location.hash.substring(2));
} else {
window.location.hash = window.location.hash.substring(2);
}
</script>