So this is what my app-routing.module.ts looks like
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { AppComponent } from './app.component';
import { IndexComponent } from './index.component';
import { ErrorComponent } from './error.component';
const routes = [
{ path: 'hira', redirectTo: 'search', pathMatch: 'full' },
{ path: 'search', component: AppComponent, pathMatch: 'full' },
{ path: 'main', component: AppComponent },
{ path: 'error', component: ErrorComponent },
{ path: '**', redirectTo: 'error'}
];
@NgModule({
imports: [ RouterModule.forRoot(routes) ],
exports: [ RouterModule ]
})
export class AppRoutingModule {}
When I go into the site e.g. www.website.com/hira
it will redirect to www.website.com/hira/search
. However if I then use that link directly (refresh it), it will not work and give me a 404.
So I'm wondering if I need to make children or something.
Also, right now I have <base href="./">
within the hira folder. And the reason why I have path: 'hira'
is because it doesn't work without it, so I was also wondering if there was a way to make it relative to the subfolder hira.
Resolved: Used hashhistory instead. Could use browserhistory but requires htaccess