title: AngularCli App routes not working on Production
body: <p>I have an Angular app with AngularCli with the following routes configuration and NgModule. The Angular App will run on production mode inside an ASP.NET Core app</p>
  
  <p>On app-routing.module.ts</p>
  
  <pre><code>import { NgModule } from '@angular/core';
  import { Routes, RouterModule } from '@angular/router';
  import { OneComponent } from './components/one.component';
  import { TwoComponent } from './components/open/two.component';
  
  const routes: Routes = [
  
    { path: '', redirectTo: 'one', pathMatch: 'full' },
    { path: 'one', component: OneComponent },
    { path: 'two', component: TwoComponent },
    { path: '**', redirectTo: 'one' }
  
  ];
  
  @NgModule({
    imports: [RouterModule.forRoot(routes, { useHash:false })],
    exports: [RouterModule]
  })
  
  export class AppRoutingModule { }
  </code></pre>
  
  <p>On app.module.ts</p>
  
  <pre><code>import { LocationStrategy, PathLocationStrategy } from '@angular/common';
  @NgModule({
    declarations: [
      AppComponent,
      OneComponent,
      TwoComponent    
    ]
    imports: [     
      AppRoutingModule,
    ],
    bootstrap: [AppComponent],
    providers: [{ provide: LocationStrategy, useClass: PathLocationStrategy }]
  })
  </code></pre>
  
  <p>In development mode routes are OK, but when I go for production (ng build --prod --aot) the routes stop working.
  If I use HashLocationStrategy routes work both development and production modes, but I have some problems because sometimes need to hit the Url two or three times when changing parameters on the url to connect with my Rest Api<br>
  The thing is that PathLocationStrategy gives me the behavior that I want but only on development and not in production.</p>
  
  <p>I need a solution that works for both modes without issues</p>
  
  <p>Any idea, thanks in advance</p>
  
  <p><strong>Update:</strong>
  If you use ASP.NET Core 2.1+, no need to use URL rewrite, the project template for angular will handle this with the NuGetPackage Microsoft.AspNetCore.SpaServices</p>