Index.html
<!DOCTYPE html>
<html lang="en" ng-app="echo">
<head>
<base href="/">
// Other JS and CSS File
</head>
<body>
<div ng-view></div>
</body>
</html>
我的应用.js
myapp
.config(function ($routeProvider, $locationProvider) {
$routeProvider
.when('/', {
templateUrl : 'pages/studies.html',
controller : 'listStudyController'
})
.when('/dashboard', {
templateUrl : 'pages/dashboard.html',
controller : 'mainController'
})
.when('/profile', {
templateUrl : 'pages/profile.html',
controller : 'mainController'
})
.otherwise({
redirectTo: '/'
});
//check browser support
$locationProvider.html5Mode({
enabled:true,
requireBase:true
});
});
.htaccess
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^(.*) /index.html [NC,L]
注意:
- 已成功从网址中删除哈希标签。
- 当我重新加载页面时,它显示错误。
未找到
在此服务器上找不到请求的 URL/配置文件。
步骤 1:编辑"httpd-vhosts.conf">
第 2 步:设置
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
允许全部覆盖解决了我的问题。