<分区>
我在 linux 环境中使用 node js (Sails) 作为后端,使用 angularJs 作为前端,在生产模式使用 nginx 来构建独立的 web。我想删除我的网址中的哈希 (#!)。 我按照这个教程
现在,只要我不刷新,我的网站就可以正常工作,每个页面都没有哈希 (#!),但是当我刷新时,它会从后端调用我的 API 或 404 not found。我按照那些教程来放置
<base href="/"/>
在我的 layout.ejs 上,但它仍然不起作用。
这是我使用状态路由 angularjs 的示例代码
(function() {
'use strict';
angular
.module('buyer.routes', ['ui.router'])
.config(function($locationProvider, $urlMatcherFactoryProvider, $urlRouterProvider, $stateProvider){
$urlRouterProvider.otherwise("/");
$urlMatcherFactoryProvider.caseInsensitive(true);
$stateProvider
.state('home', {
url: '/',
templateUrl: 'templates/buyer/buyer-index.html',
controller: 'BuyerController',
controllerAs: 'vm'
})
.state('home.testi', {
url: 'testimoni',
templateUrl: 'templates/buyer/buyer-testimoni.html',
controller: 'BuyerTestimoniController',
controllerAs: 'vm',
data : { pageTitle: 'Testimoni page'}
})
$locationProvider.hashPrefix('');
$locationProvider.html5Mode(true);
})
}());
我的代码有什么问题? 谢谢