【发布时间】:2014-07-09 14:44:54
【问题描述】:
这是我的路由器:
var app = angular.module('tradePlace', ['ngRoute', 'tradeCntrls']);
app.config(['$routeProvider', '$locationProvider', function($route, $location) {
$route.
when('/', {
redirectTo: '/index'
}).
when('/index', {
templateUrl: './includes/templates/index.php',
controller: 'indexCntrl'
}).
when('/register', {
templateUrl: './includes/templates/register.php',
controller: 'indexCntrl'
}).
otherwise({
redirectTo: '/index'
});
$location.html5Mode(true);
}])
我的 html5 模式为 true,所以现在 URL 中没有 #。
如果我访问 mysite.com/,它会将我重定向到 /index,但是当我重新加载页面 (f5) 或访问 mysite.com/index 时,我会收到 404 错误。
有没有办法解决这个问题?还是不使用html5模式?
【问题讨论】:
标签: javascript html angularjs