Configure Amazon S3 static site with Angular JS ui.router html5Mode(true) on page refresh

前端 未结 4 1287
栀梦
栀梦 2020-12-10 04:04

How can I configure an Amazon S3 static webpage to properly route Angular ui.router html5Mode routes? On page refresh, it will make a request for a file that doesn\'t exist,

4条回答
  •  -上瘾入骨i
    2020-12-10 04:42

    In the Frequently Asked Questions, they rewrite almost everything to serve the index.html page. For HTML5 fallback mode you need to use #!/ (hashbang).

    You could change this:

      #/
    

    with

      #!/
    

    More details on this answer: https://stackoverflow.com/a/16877231/1733117

    You may also need to configure your app for using that prefix:

    angular.module(...)
    
    ...
    
    .config(function($locationProvider) {
      $locationProvider.html5Mode(true).hashPrefix('!');
    })
    

提交回复
热议问题