ngRoute
该网站在http://www.athimannil.com/上运行良好,但不幸的是页面http://www.athimannil.com/about在刷新 URL 时无法正常工作:(
是否需要在 JavaScript 代码中添加任何额外内容?
var app = angular.module('app',['ngRoute']);
app.config(function($routeProvider, $locationProvider) {
$locationProvider.html5Mode(true);
$routeProvider
.when('/', {
templateUrl: 'home.html',
controller: 'homecontroller'
})
.when('/about', {
templateUrl: 'about.html',
controller: 'aboutController'
})
.when('/portfolio', {
templateUrl: 'portfolio.html',
controller: 'portfolioController'
})
.when('/contact', {
templateUrl: 'contact.html',
controller: 'contactController'
})
.when('/cv', {
templateUrl: 'cv.html',
controller: 'cvController'
})
.otherwise({
redirectTo: '/'
});
});
.htaccess
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]