问题描述
我还尝试将 $locationProvider.html5Mode(true); 中的 ui-routing 和 base href 设置为 <base href="http://localhost/rootfoldername/"> 它会删除散列,但刷新时会出现 404 错误.
I also tried by setting the $locationProvider.html5Mode(true); in ui-routing and base href to <base href="http://localhost/rootfoldername/"> it removes hash but on refresh it gives 404 Error.
请帮帮我...
推荐答案
正如其他人所说,启用 html5 模式并添加 baseURL 可以解决问题,但是仍然缺少一个难题,那就是服务器的重写规则配置.
As others said enabling html5 mode and adding a baseURL does the trick, however one piece of the puzzle is still missing and thats the rewrite rules configuration for your server.
抛出 404 的原因是服务器没有将所有路由重定向到 angularJS 应用程序.这就是重写规则出现的地方.
The reason why the 404 is thrown is because the server doesn't redirect all routes to the angularJS app. This is where rewrite rules come on.
对于 apache:如何在 apache 中重写 urlangularjs 应用程序的 htaccess
对于 IIS:如何配置 IIS 以在 HTML5 模式下重写 AngularJS 应用程序的 URL?
这篇关于AngularJS - 启用没有 404 错误的 HTML5 模式页面刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!




大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)