How do I configure IIS for URL Rewriting an AngularJS application in HTML5 mode?

后端 未结 7 2248
春和景丽
春和景丽 2020-11-22 12:12

I have the AngularJS seed project and I\'ve added

$locationProvider.html5Mode(true).hashPrefix(\'!\');

to the app.js file. I want to confi

7条回答
  •  北恋
    北恋 (楼主)
    2020-11-22 12:40

    The issue with only having these two conditions:

      
      
    

    is that they work only as long as the {REQUEST_FILENAME} exists physically on disk. This means that there can be scenarios where a request for an incorrectly named partial view would return the root page instead of a 404 which would cause angular to be loaded twice (and in certain scenarios it can cause a nasty infinite loop).

    Thus, some safe "fallback" rules would be recommended to avoid these hard to troubleshoot issues:

      
      
      
    

    or a condition that matches any file ending:

    
      
      
    
    

提交回复
热议问题