.htaccess Angular2路由重定向到错误的url

.htaccess Angular2路由重定向到错误的url,.htaccess,angular2-routing,.htaccess,Angular2 Routing,我在apache服务器上的子文件夹/draft中有一个angular2应用程序。 为了让它工作,我在/draft中添加了这个.htaccess: Options Indexes FollowSymLinks RewriteRule ^index\.html$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /draft/index.html [L] 并将其添

我在apache服务器上的子文件夹
/draft
中有一个angular2应用程序。 为了让它工作,我在/draft中添加了这个
.htaccess

Options Indexes FollowSymLinks

RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /draft/index.html [L]
并将其添加到标题中的
/draft/index.html


我的组件和其他类型脚本文件位于/draft/app/, 我的
/draft/systemjs.config.js
如下所示:

(功能(全局){
System.config({
路径:{
“npm:”:“/draft/node_modules/”
},
地图:{
应用程序:'/draft/app',
“@angular/core”:“npm:@angular/core/bundles/core.umd.js”,
'rxjs':'npm:rxjs',
// ...
},
套餐:{
应用程序:{
main:“./main.js”,
defaultExtension:'js'
},
rxjs:{
defaultExtension:'js'
}
}
});
})(本条);
这一切都很好,但当我尝试添加路由时,出现了一些问题。 当用户转到
/draft/foo
时,我希望显示组件foo组件。
但是,当用户转到
/draft/foo
时,foo组件将按预期显示,但由于某些原因,url将更改为
/draft/draft/draft/foo

这是我的
/draft/app/app.routing.js

/。。。
施工许可:路线=[
{
路径:'draft/foo',
组件:FooComponent
}
];
导出常量路由:ModuleWithProviders=RouterModule.forRoot(appRoutes);
我将路由常量添加到我的AppModule的imports数组中,
/draft/app/app.module.ts

/。。。
@NGD模块({
导入:[BrowserModule,HttpModule,路由],
声明:[AppComponent,FooComponent],
引导:[AppComponent]
})
导出类AppModule{}
/draft/app/components/AppComponent.ts
如下所示:

从'@angular/core'导入{Component};
@组成部分({
选择器:“我的应用程序”,
模板:“”
})
导出类AppComponent{}


那么为什么
/draft/foo
被重定向到
/draft/draft/draft/foo
,我能做些什么来阻止它呢?

显然,基数不正确。 在以下基础上,一切正常

<base href="http://localhost/draft/" />