I want to start/load my site from http://domain/dist/index.html
I have pointed my virtual host to dist/index.html, so I can load my site using this http://domain
My app.routes.ts
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { PathLocationStrategy ,LocationStrategy } from '@angular/common';
import { SelectivePreloadingStrategy } from './selective-preloading-strategy';
import { NotFoundComponent } from './not-found/not-found.component';
const routes: Routes = [
{ path: "", loadChildren: "app/site/site-layout/site-layout.module#SiteLayoutModule" },
{ path: "admin", loadChildren: "app/admin/admin-layout/admin-layout.module#AdminLayoutModule" },
{ path: "**", component: NotFoundComponent }
];
@NgModule({
imports: [ RouterModule.forRoot(
routes,
{ preloadingStrategy: SelectivePreloadingStrategy }
)],
exports: [ RouterModule ],
providers: [
{ provide: LocationStrategy, useClass: PathLocationStrategy },
]
})
export class AppRoutingModule {}
Using above strategy, everything is fine, but I have http:/domain/admin is different part of my site, so when I directly open this from url, then it will give me 404 error. Also on all other routes, if I load it from url, it will give 404.
Now I have tried with HashLocationStrategy, With this 404 error issue solved. But If I am at http://domain/# and when I edit url on same window e.g. http://domain/#/admin then css of front layout will be there. I don't want this css at admin. It's conflict between two layout css. On second reload it's fine.
Is there any solution for that?
Any option for angular to work without hashtag and not face page reload 404 error.
Just for information I have server call to NodeJS. But I want my website first load from angular dist, not from server.
Thanks.