title: Angular 2 access child routes from URL
body: <p>Using the following Angular 2 Routes in my main module (app.module), i am able to navigate successfully through all the referenced component views.</p>
  
  <pre><code>const routes: Routes = [
      {path: '', redirectTo: 'home', pathMatch: 'full'},
      {path: 'home', component: HomeComponent},
      {path: 'other', component: OtherComponent},
      {path: 'extra', component: ExtraComponent},
      {path: 'group', component: GroupComponent,
          children: [
          {path: '', component: FirstPageComponent},
          {path: 'comp1', component: FirstPageComponent},      
          {path: 'comp2', component: SecondPageComponent},
          {path: 'comp3', component: ThirdPageComponent},
          {path: 'comp4', component: FourthPageComponent}
          ]
      },
      {path: '**', component: HomeComponent}
  ];
  </code></pre>
  
  <p>Also, using the LocationStrategy, described here :
  <a href="https://angular.io/docs/ts/latest/guide/router.html#!#browser-url-styles" rel="noreferrer">LocationStrategy and browser URL styles</a></p>
  
  <p>i am able to access </p>
  
  <blockquote>
    <p><a href="http://localhost:3000/extra" rel="noreferrer">http://localhost:3000/extra</a></p>
  </blockquote>
  
  <p>by typing it directly on the address bar, since the path is redirected to the root of the application and handled by Angular's routing.</p>
  
  <p>But i cannot directly access a child route like </p>
  
  <blockquote>
    <p><a href="http://localhost:3000/group/comp2" rel="noreferrer">http://localhost:3000/group/comp2</a></p>
  </blockquote>
  
  <p>This produces 404 errors because all the resources being requested start from the path <a href="http://localhost:3000/group/" rel="noreferrer">http://localhost:3000/group/</a>... which is not correct.</p>
  
  <p>In-app navigation through RouterLink directives works just fine.</p>
  
  <p>Any advice would be appreciated.</p>
  
  <h3>UPDATE :</h3>
  
  <p>It appears that the problem is not caused by the Angular routing mechanism or the web server configuration. The routing is working just fine even when reloading or typing the path in the address bar, since the lite-server is configured to redirect all paths to index.html.</p>
  
  <p>The problem is that index.html is loading some scripts and stylesheets using relative paths, as does one of my components (loads a config file).</p>
  
  <p>So when reloading/typing the path </p>
  
  <pre><code>http://localhost:3000/group/comp2
  </code></pre>
  
  <p>the server does redirect to index.html which is trying to access for example :</p>
  
  <pre><code>&lt;script type="text/javascript" src="assets/vendor/bootstrap/js/bootstrap.min.js" &gt;&lt;/script&gt;
  </code></pre>
  
  <p>but the full src path has now become : </p>
  
  <pre><code>src = "group/assets/vendor/bootstrap/js/bootstrap.min.js"
  </code></pre>
  
  <p>Which does not exist.</p>
  
  <p>I could use absolute paths to tackle this problem, but since my production environment is not determined and the root path of the application is unknown, this is not possible. </p>
  
  <p>I have been trying to find a way to determine the root path of the application at runtime and make src=".." links dynamic but couldn't work it out, so i decided to edit my routes so that all of them are siblings and none of them has child routes.</p>
  
  <p>Thanks for the help and sorry for the misunderstanding of the issue.</p>