Angular.js ルートで大量の記事やスタック オーバーフローの質問を読んだ後でも、手動で更新すると「見つかりません」というエラーが表示されます。
手順:
- を参照
localhost
--> 私の設定 (下記) により、 に移動しlocalhost/home
ます。ビューとすべてが正常にロードされます。 - ブラウザで更新を押します->ブラウザはこれを表示します
Not Found: the requested /home is not found on this server
この質問はおそらく、ページを更新すると「ページが見つかりません」と表示されるのに最も似ています
私の構成
// 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="/">
- angular 1.2.1にアップグレード
これが私が試したhtaccessルールです。どれも機能しません。
<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>