AngularJS - Enable HTML5 Mode Page Refresh Without 404 Errors(AngularJS - 启用没有 404 错误的 HTML5 模式页面刷新)
问题描述
我还尝试将 $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 模式页面刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:AngularJS - 启用没有 404 错误的 HTML5 模式页面刷新
基础教程推荐
- 原生拖动事件后如何获取 mouseup 事件? 2022-01-01
- 在 contenteditable 中精确拖放 2022-01-01
- npm start 错误与 create-react-app 2022-01-01
- 即使用户允许,Gmail 也会隐藏外部电子邮件图片 2022-01-01
- fetch 是否支持原生多文件上传? 2022-01-01
- Bokeh Div文本对齐 2022-01-01
- 如何添加到目前为止的天数? 2022-01-01
- Fabric JS绘制具有活动形状的多边形 2022-01-01
- Bootstrap 模态出现在背景下 2022-01-01
- 检查 HTML5 拖放文件类型 2022-01-01
