I'm developing one Angular 5 application deployed on Azure App Service. My problem is that when I try to access with a direct link my application redirect me to home page.
These are my application routes:
// Imports
@NgModule({
declarations: [
// declaratins
],
imports: [
// modules
RouterModule.forRoot([
{ path: 'login', component: LoginComponent },
{ path: 'home', component: HomeComponent, canActivate: [AuthGuard] },
{ path: 'search', component: SearchComponent, canActivate: [AuthGuard] },
{ path: '', redirectTo: 'home', pathMatch: 'full', canActivate: [AuthGuard] }
]),
// modues
],
providers: [
// Imports
],
bootstrap: [AppComponent]
})
export class AppModule { }
I've followed the deployment angular's instruction changing the web.config with following:
<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>
When I navigate inside application I can view the URL change correctly but if I try navigate directly a link like https://host/search I will redirect to https://host/home.
How can I resolve this problem? Thanks