我正在尝试在共享主机上部署我的角度应用程序,但是有问题。刷新浏览器页面后,路由网址已更改。例如,页面刷新后url为http://myapp.com/items
,看起来像http://myapp.com/items/items
,那么我的应用程序什么也不会呈现。我没办法解决问题。请问我英语不好。
const routes: Routes = [
{ path: 'item/:id', component: ItemDetailsFormComponent},
{ path: 'items', component: DataTableComponent},
{ path: '', redirectTo: '/items', pathMatch: 'full'}
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }
这是一个Apache配置
# Don't rewrite files or directories
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
# Rewrite everything else to index.html
# to allow html5 state links
RewriteRule ^ index.html [L]