在阅读Angular.js路线上的大量写入和堆栈溢出问题之后,当我手动刷新时,我仍然收到“Not Found”错误.
脚步:
>浏览到本地主机 – >由于我的配置(下面),我被带到了localhost / home.意见和一切加载罚款.
>在浏览器中点击刷新 – >浏览器显示“未找到”:在此服务器上找不到请求/ home
这个问题可能最像Refreshing page gives “Page not found”
我的配置
// Routing configuration. angular.module('myModule') .config(['$routeProvider','$locationProvider',function ($routeProvider,$locationProvider) { // Enable pushState in routes. $locationProvider.html5Mode(true); $routeProvider .when('/home',{ templates: { layout: '/views/home.html' },title: 'Welcome!' }) .when('/launchpad',{ templates: { layout: '/views/layouts/default.html',content: '/views/partials/profile.html' },title: "Launchpad" }) .otherwise({ redirectTo: '/home' }); } ]);
我做过的其他事情
>在我的index.html中,我已经有< base href =“/”>
>升级到角度1.2.1
这是我尝试过的htaccess规则.没有工作.
从Refreshing page gives “Page not found”
<ifModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !index RewriteCond %{REQUEST_URI} !.*\.(css|js|html|png) #Add extra extensions needed. RewriteRule (.*) index.html [L] </ifModule>
从http://ericduran.io/2013/05/31/angular-html5Mode-with-yeoman/
<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*) /index.html/#!/$1 </IfModule>
解决方法
这个.htaccess设置对我来说很好
<IfModule mod_rewrite.c> Options +FollowSymlinks RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_URI} !^/$ RewriteRule (.*) /#!/$1 [NE,L,R=301] </IfModule>