I uploaded to production my first Angular project. The website available here: http://urigross.com When I type in the address field "urigross.com" the website works fine. When I refresh the page I get an error message. It also happens when I type in the address field the exact route such as "www.urigross.com/heb/about" for example. It happens with every route that I try. Error message Are :
"Not Found The requested URL was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request."
I tried contacting the site support and they told me that my angular routing may be not configured right. The website works perfectly locally on my pc with "ng s" command. I tried searching on stackoverflow but the results were for php and not angular projects.
my routing code:
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { HomeComponent } from 'src/app/components/home/home.component';
import { AboutComponent } from 'src/app/components/about/about.component';
import { ContactComponent } from 'src/app/components/contact/contact.component';
import { Page404Component } from 'src/app/components/page404/page404.component';
import { PlywoodHomeComponent } from 'src/app/components/plywood/plywood-home/plywood-home.component';
import { MdfHomeComponent } from 'src/app/components/mdf/mdf-home/mdf-home.component';
import { TegoHomeComponent } from 'src/app/components/tegoShuttering/tego-home/tego-home.component';
import { HardwoodsHomeComponent } from 'src/app/components/hardwood/hardwoods-home/hardwoods-home.component';
import { MapComponent } from 'src/app/components/map/map.component';
import { OsbFjHomeComponent } from 'src/app/components/OsbFj/osb-fj-home/osb-fj-home.component';
const routes: Routes = [
{ path: 'heb/home', component: HomeComponent},
{ path: 'heb/about', component: AboutComponent},
{ path: 'heb/plywood1', component: PlywoodHomeComponent},
{ path: 'heb/mdf', component: MdfHomeComponent},
{ path: 'heb/hardwood', component: HardwoodsHomeComponent},
{ path: 'heb/plywood2', component: TegoHomeComponent},
{ path: 'heb/plywood3', component: OsbFjHomeComponent},
{ path: 'heb/contact', component: ContactComponent},
{ path: 'heb/map', component: MapComponent},
{ path: 'heb/page404', component: Page404Component},
{ path: '', redirectTo: '/heb/home', pathMatch: 'full' }, // Default redirect ( When inserting Domain name).
// { path: '**', component: Page404Component }
{ path: '**', redirectTo: '/heb/page404', pathMatch: 'full'} // Redirect when invalid address typed
];
@NgModule({
declarations: [],
imports: [
RouterModule.forRoot(routes)
],
exports: [RouterModule]
})
export class RoutingModule { }