2016-08-21 95 views
0

當我去www.myweb.com/something網頁將顯示消息:路由默認的404工作不

{ 
    "status": 404, 
    "message": "No Content" 
} 

這裏是我的app.routes:

export const routes: RouterConfig = [ 
    { path: '', redirectTo: 'account', pathMatch: 'full' }, 
    { path: 'account', component: Account }, 
    { path: 'followers', component: Followers }, 
    { path: 'explore/:id', component: Explore }, 
    { path: '**', redirectTo: 'account' }, 
    ]; 

進出口使用角通用的,所以我有另一個文件叫server.ts白衣這個代碼:

// Routes with html5pushstate 
// ensure routes match client-side-app 
app.get('/', ngApp); 
app.get('/followers', ngApp); 
app.get('/followers/*', ngApp); 
app.get('/account', ngApp); 
app.get('/account/*', ngApp); 
app.get('/explore', ngApp); 
app.get('/explore/*', ngApp); 

問題在哪裏?謝謝!

回答

1

你可以試試以下,

// notice the slash in front of account navigation 
{ path: '**', redirectTo: '/account' } 

它使導航絕對如果路徑不匹配。

希望這有助於!

+0

加載資源失敗:服務器迴應狀態爲404(未找到):( –

+0

路由是否適用於www.myweb.com/account? –

+0

是的,它工作正常 –