ハッシュ#
const routes: Routes = [
// routes here
];
@NgModule({
imports: [
... other imports
RouterModule.forRoot(routes, { useHash: true }) // .../#/users/
],
...
})
export class SomeModule { }
または以下のルールを追加、ドメインのS3コンソールの編集リダイレクションルールセクションではS3
の設定に使用するアプリのルートを設定:
を
<RoutingRules>
<RoutingRule>
<Condition>
<HttpErrorCodeReturnedEquals>404</HttpErrorCodeReturnedEquals>
</Condition>
<Redirect>
<HostName>domain.com</HostName>
<ReplaceKeyPrefixWith>#/</ReplaceKeyPrefixWith>
</Redirect>
</RoutingRule>
</RoutingRules>
これをindex.htmlに入れます
<script language="javascript">
if (typeof(window.history.pushState) == 'function') {
window.history.pushState(null, "Site Name", window.location.hash.substring(2));
} else {
window.location.hash = window.location.hash.substring(2);
}
</script>
ありがとうございます! – Lilrom
私は助けてうれしい! –