Angular 4 remove hash(#) from url

后端 未结 2 1439
小蘑菇
小蘑菇 2020-12-18 16:43

my app.module.ts

@NgModule({
.......
  providers: [
....
    { provide: LocationStrategy, useClass: HashLocationStrategy},
....
]
});

when

2条回答
  •  遥遥无期
    2020-12-18 17:25

    You should rewrite the URL rules.For every server rules will be diifferent and you can try this for IIS.

    => Create web.config in src folder and copy below code.

            
            
    
            
              
                
                  
                    
                    
                      
                      
                    
                    
                  
                
              
            
    
            
    

    => add web.config path to angular-cli.json file:

        "assets": [
            "assets",
            "favicon.ico",
            "web.config"
        ],
    

    => Let’s build: ng build --prod

提交回复
热议问题