现在,我网站的网址看起来像这样,因为我使用的是 此处 描述的方法
http://localhost:4200/#/cadastro
是否可以删除 url 中的哈希值而不出现 404 错误?
编辑:添加了路由器模块
const appRoutes: Routes = [
{ path: '', component: HomeComponent },
{ path: 'cadastro', component: CadastroNoivosComponent },
{ path: '**', component: HomeComponent }
];
export const routing = RouterModule.forRoot(appRoutes);
原文由 Emilio Weba 发布,翻译遵循 CC BY-SA 4.0 许可协议
如果您按照 此处 所述使用 PathLocationStrategy ,则可以删除 URL 中的散列。
但是摆脱 404 错误需要一些服务器端调整。一种快速简便的方法是将您的服务器配置为在请求
http://yourhost/*
形式的任何 URL 时加载主页。