作者:mobiledu2502905727 | 来源:互联网 | 2023-05-19 03:36
Iamgettingaservedthe404pagewheneverI:无论什么时候,我都会收到404页面的服务:1.)refreshanypageonmyA
I am getting a served the 404 page whenever I :
无论什么时候,我都会收到404页面的服务:
1.) refresh any page on my Angularjs site (besides the root page)
1.)刷新我的Angularjs站点上的任何页面(除了根页面)
or
要么
2.) click Back to go from a 404 page to the root page (the root page will be a 404)
2.)单击“返回”从404页面转到根页面(根页面为404)
Here is my .config()
code
这是我的.config()代码
'use strict';
angular.module('mmApp', ['ngResponsiveImages'])
.config(function ($locationProvider, $routeProvider) {
$locationProvider.html5Mode(true);
$locationProvider.hashPrefix = '!';
$routeProvider
.when('/', {
templateUrl: '/views/design.html',
controller: 'MainCtrl'
})
.when('/about', {
templateUrl: '/views/about.html',
controller: 'MainCtrl'
})
.when('/contact', {
templateUrl: '/views/contact.html',
controller: 'MainCtrl'
})
.otherwise({
redirectTo: '/'
});
});
I have come across this similar question but do not quite understand the answers or how to implement them.
我遇到过类似的问题,但不太了解答案或如何实现它们。
AngularJS - Why when changing url address $routeProvider doesn't seem to work and I get a 404 error
AngularJS - 为什么在更改url地址$ routeProvider似乎不起作用时我收到404错误
The accepted answer says to setup Apache to reconfigure all paths to the root. My site is on Github Pages. I have a .htaccess
file in my gh-pages
repo but I have no idea how to configure it to send all paths to the root.
接受的答案是设置Apache以重新配置到根的所有路径。我的网站是在Github Pages上。我的gh-pages repo中有一个.htaccess文件,但我不知道如何配置它以将所有路径发送到根目录。
The answer says another thing to consider is using the
element like
but where would I place that? In my index.html
? If so at the top or bottom of that file? Also, would I just leave the href
value to /
?
答案说另外要考虑的是使用像这样的元素,但是我会把它放在哪里?在我的index.html中?如果是这样在该文件的顶部或底部?另外,我只是将href值保留为/?
4 个解决方案