最近想把以前一个用Asp.Net MVC做的项目前端改成用Angularjs,在路由那里,因为Angularjs的路由嵌套很复杂,就用了angular-ui-router,
不过不管是用Angularjs的router还是用angular-ui-router,在地址栏显示的是“http://localhost:8390/home.html#/index”,看起来非常难看,而看了其他网上用Angularjs做的网站,
如“http://angularjs.cn/latest”、“https://www.ele.me/shop/902882/rate”,
这些都看不到“.html”、“#”这种,
或者如“https://angular-ui.github.io/ui-router/site/#/api/ui.router”这种就只有一个“#”分隔。
请教下各位大神怎么做成这种效果?而不是“xxx.html#/xxx”这种不好看的样式。谢谢!
最终解决方案详见Chobits大神的内容,已经完美解决。
https://github.com/angular-ui/ui-router/wiki/Frequently-Asked-Questions#how-to-configure-your-server-to-work-with-html5mode
http://readystate4.com/2012/05/17/nginx-and-apache-rewrite-to-support-html5-pushstate/
http://stackoverflow.com/questions/25730797/asp-net-mvc-hosting-angular-app-with-html5mode-and-routing
http://www.codeproject.com/Articles/806500/Getting-started-with-AngularJS-and-ASP-NET-MVC-P
header里设置
新建app文件夹 把index.html放入
Try changing your RouteConfig.cs, like this:
Azure IIS Rewrites: