Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/90.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
AngularJS-启用HTML5模式页面刷新,无404错误_Angularjs_Html_Angular Ui Router - Fatal编程技术网

AngularJS-启用HTML5模式页面刷新,无404错误

AngularJS-启用HTML5模式页面刷新,无404错误,angularjs,html,angular-ui-router,Angularjs,Html,Angular Ui Router,我还尝试设置$locationProvider.html5Mode(true)在ui路由和base href to中,它删除散列,但在刷新时会出现404错误 请帮我解决…正如其他人所说,启用html5模式并添加baseURL可以解决问题,但是仍然缺少一个难题,那就是服务器的重写规则配置 抛出404的原因是服务器没有将所有路由重定向到angularJS应用程序。这就是重写规则的由来 对于apache: 对于IIS:您需要将Web服务器配置为具有所谓的404回退。这就是它的设置。我尝试将重写代码放在

我还尝试设置
$locationProvider.html5Mode(true)
在ui路由和base href to
中,它删除散列,但在刷新时会出现404错误


请帮我解决…

正如其他人所说,启用html5模式并添加baseURL可以解决问题,但是仍然缺少一个难题,那就是服务器的重写规则配置

抛出404的原因是服务器没有将所有路由重定向到angularJS应用程序。这就是重写规则的由来

对于apache:


对于IIS:

您需要将Web服务器配置为具有所谓的404回退。这就是它的设置。我尝试将重写代码放在htaccess中,但我在刷新时仍收到相同的404错误。
RewriteCond%{REQUEST_FILENAME}-s[OR]RewriteCond%{REQUEST_FILENAME}-l[OR]RewriteCond%{REQUEST_FILENAME}-d RewriteRule^.$-[NC,l]RewriteRule^(.*)/index.html[NC,l]
确保重写规则指向的/index.html确实存在,并且包含angular应用程序。如果这仍然不起作用,您可能希望在您的问题中添加其他信息,以便我们可以进一步帮助您,比如404错误页面的屏幕截图。我的代码结构:-apache>htdocs>projectname>index.html和.htaccess都存在,是否有错误请告诉我。