删除哈希后的AngularJs页面刷新问题 [英] AngularJs Page Refresh Issue after removed hash
本文介绍了删除哈希后的AngularJs页面刷新问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Index.html
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>
myapp.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
.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]
注意:
-成功从网址中删除了哈希标签。
-重新加载页面时显示错误。
Note:
- Removed hash tag from url successfully.
- When I reloading page It display error.
未找到
在此服务器上未找到请求的URL / profile。
Not Found
The requested URL /profile was not found on this server.
推荐答案
步骤1:
编辑 httpd-vhosts.conf
步骤2:
设置
step 1:
Edit "httpd-vhosts.conf"
step 2:
Set
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
AllowOverride All 解决了我的问题。
这篇关于删除哈希后的AngularJs页面刷新问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文